<template>
  <div style="height:100%;width:100%;position:relative;">
      <div class="page-container">
          <div class="page-top" style="border:1px solid #CCC">
              <div class="search-title">快速查询</div>
              <el-input v-model="barcode" placeholder="请输入检验目的代码、检验目的名称、输入码" @keyup.enter.native="filterData" clearable :disabled="changeflag" style="width: 280px;"></el-input>
               <div mar width="130px" align="right" style="color: #666;margin-left:10px;">
                      <span>工作组：</span>
                      <el-select v-model="searchParam.labgroupid" placeholder="请选择" clearable @change="initData" style="width:105px">
                          <el-option v-for="item in glist" :key="item.labgroupid" :label="item.labgroupname" :value="item.labgroupid"></el-option>
                      </el-select>
               </div>
              <div class="top-deal">
                  <el-button icon="el-icon-search" type="primary" @click="filterData" :disabled="changeflag">查询</el-button>
                  <el-button icon="el-icon-plus" @click="MainOpenDialog(1)" :disabled="changeflag">新增</el-button>
                  <el-button icon="el-icon-delete" @click="MainOpenDialog(2)" :disabled="activeName!='baseinfo'|| changeflag">删除</el-button>
                  <el-button icon="el-icon-document" @click="MainOpenDialog(3)" :disabled="!changeflag">保存</el-button>
                  <el-button icon="el-icon-close" @click="MainOpenDialog(4)" :disabled="!changeflag">取消</el-button>
                  <el-button icon="el-icon-upload2" @click="ExportCsv">导出</el-button>
                  <el-button icon="el-icon-files" @click="ImportCsv">导入</el-button>
                  <div class="upload-button">
                      <el-upload ref="upload" 
                          :action="url" accept=".dat" 
                          :before-upload="beforeUploadFile" :on-change="fileChange" :show-file-list="showFile"
                          :data="updata" :http-request="uploadOpt">
                          <el-button size="small" plain>选择文件</el-button>
                          <!-- <div slot="tip" class="el-upload__tip">只能上传DAT(*dat)文件，且不超过10M</div> -->
                      </el-upload>
                  </div>
              </div>
          </div>
          <div class="page-bottom">
              <rm-layout-right splitcolor="#FFFFFF" movingcolor="#CCFFFF" :splitwidth=5 :fixsize=694>
                  <div class="middle-left" style="height:100%">
                      <vxe-table show-overflow ref="xTable" :data.sync="bactPurposeList" class="mytable-style" height="auto" border :loading="bactPurposeLoading" :sort-config="{trigger: 'cell'}" :keyboard-local-config="keyLocalConfig" highlight-current-row resizable stripe header-align="center" :row-class-name="rowClassName" @current-change="currentChangeEvent">
                          <vxe-table-column field="purposeno" title="检验目的代码" width="80" align="center"></vxe-table-column>
                          <vxe-table-column field="purposename" title="检验目的名称" width="160"></vxe-table-column>
                          <vxe-table-column field="specimen_name" title="默认标本类型" width="80"></vxe-table-column>
                          <vxe-table-column field="mediumgroupname" title="默认培养基组合" width="120"></vxe-table-column>
                          <vxe-table-column field="smearflagname" title="涂片专用" align="center" width="80"></vxe-table-column>
                          <vxe-table-column field="samplenorules" title="编号规则" width="80"></vxe-table-column>
                          <vxe-table-column field="inputcode" title="输入码" width="80"></vxe-table-column>
                          <vxe-table-column field="seq" title="序号" align="center" width="40"></vxe-table-column>
                          <vxe-table-column field="specimen_comm" title="默认标本备注" width="120"></vxe-table-column>
                          <vxe-table-column field="minreporthour" title="最小发报告小时数" width="70"></vxe-table-column>
                          <vxe-table-column field="maxreporthour" title="最大发报告小时数" width="70"></vxe-table-column>
                          <vxe-table-column field="exbarcount" title="附加条码数" width="60"></vxe-table-column>
                          <vxe-table-column field="mdlname" title="默认输入模板" width="100"></vxe-table-column>
                          <vxe-table-column field="bloodculture" title="血培养标记" align="center" width="50">
                              <template v-slot="{ row }">
                                  <el-checkbox v-model="row.bloodculture" true-label="1" false-label="0" disabled></el-checkbox>
                              </template>
                          </vxe-table-column>
                          <vxe-table-column field="purposekind" title="检验目的归类" width="100"></vxe-table-column>
                          <vxe-table-column field="labgroupname" title="检验工作组" width="100"></vxe-table-column>
                      </vxe-table>
                  </div>
                  <template v-slot:fix>
                      <div class="middle-right" style="height:100%;">
                          <el-tabs v-model="activeName" style="height:100%;" type="border-card" ref="tabs">
                              <el-tab-pane label="基本信息" name="baseinfo" class="baseinfo">
                                  <table>
                                      <tr>
                                          <td class="must-param" width="120" align="right">检验目的代码</td>
                                          <td width="80">
                                              <el-input v-model="addParam.purposeno" :disabled="operatetype != 1" @input="hasChange" ref="input11" @keyup.enter.native="nextFocus(1, 1)"></el-input>
                                          </td>
                                          <td width="80" align="right">序号</td>
                                          <td width="50">
                                              <el-input v-model="addParam.seq" @input="hasChange" ref="input12" @keyup.enter.native="nextFocus(1, 2)"></el-input>
                                          </td>
                                          <td width="220" align="right">默认标本类型</td>
                                          <td colspan="3">
                                              <rm-ddl-common :appendtobody="true" datatype="specimen" v-model="addParam.speicimencode" @change="hasChange" ref="input13" @keyup.enter.native="nextFocus(1, 2)" style="width:100%"></rm-ddl-common>
                                          </td>
                                          <td></td>
                                      </tr>
                                      <tr>
                                          <td class="must-param" align="right">检验目的名称</td>
                                          <td colspan="3">
                                              <el-input v-model="addParam.purposename" @input="hasChange(1)" ref="input14" @keyup.enter.native="nextFocus(1, 4)"></el-input>
                                          </td>
                                          <td align="right">默认标本备注</td>
                                          <td colspan="3">
                                              <!-- <rm-ddl-common :appendtobody="true" datatype='seccode' kindno='SpecimenComm' v-model="addParam.specimen_comm" @change="hasChange" ref="input15" style="width:100%"></rm-ddl-common> -->
                                              <el-select v-model="addParam.specimen_comm" filterable placeholder="请选择" clearable @blur="selectBlur" ref="input15" @keyup.enter.native="nextFocus(1, 5)" style="width: 100%;">
                                                  <el-option v-for="(item, index) in specimencommList" :key="index + item.data" :label="item.property" :value="item.data">
                                                  </el-option>
                                              </el-select>
                                          </td>
                                          <td></td>
                                      </tr>
                                      <tr>
                                          <td align="right">默认培养基组合</td>
                                          <td colspan="3">
                                              <el-select v-model="addParam.mediumgroupno" filterable placeholder="请选择" clearable @change="hasChange" ref="input16" @keyup.enter.native="nextFocus(1, 6)" style="width: 100%;">
                                                  <el-option v-for="item in mediumgroupList" :key="item.value" :label="item.label" :value="item.value"></el-option>
                                              </el-select>
                                          </td>
                                          <td align="right">阴性结果默认输入模板</td>
                                          <td colspan="3">
                                              <el-select v-model="addParam.definputmdl" filterable placeholder="请选择" clearable @dblclick.native="chooseChargeRule(0)" @change="hasChange" ref="input17" @keyup.enter.native="nextFocus(1, 7)" style="width: 100%;">
                                                  <el-option v-for="item in dtmdlList" :key="item.inputmdlid" :label="item.mdlname" :value="item.inputmdlid"></el-option>
                                              </el-select>
                                          </td>
                                          <td></td>
                                      </tr>
                                      <tr>
                                          <td align="right">类别</td>
                                          <td colspan="3">
                                              <el-select v-model="addParam.purposekind" filterable placeholder="请选择" clearable @blur="selectBlur1" @change="hasChange" ref="input18" @keyup.enter.native="nextFocus(1, 8)" style="width: 100%;">
                                                  <el-option v-for="item in pkList" :key="item.data" :label="item.display" :value="item.data"></el-option>
                                              </el-select>
                                          </td>
                                          <td align="right">是否涂片</td>
                                          <td width="100">
                                              <el-select v-model="addParam.smearflag" filterable placeholder="请选择" clearable @change="hasChange" ref="input19" @keyup.enter.native="nextFocus(1, 9)">
                                                  <el-option v-for="item in smearflagList" :key="item.value" :label="item.name" :value="item.value"></el-option>
                                              </el-select>
                                          </td>
                                          <td align="right">
                                              <el-checkbox v-model="addParam.bloodculture" true-label="1" false-label="0" @change="hasChange"></el-checkbox> 血培养
                                          </td>
                                          <td></td>
                                      </tr>
                                      <tr>
                                          <td align="right">输入码</td>
                                          <td>
                                              <el-input v-model="addParam.inputcode" maxlength="20" @input="hasChange" ref="input110" @keyup.enter.native="nextFocus(1, 10)"></el-input>
                                          </td>
                                          <td align="right">附加条码数</td>
                                          <td>
                                              <el-input v-model="addParam.exbarcount" @input="hasChange" ref="input111" @keyup.enter.native="nextFocus(1, 11)"></el-input>
                                          </td>
                                          <td align="right">录入时附加计费</td>
                                          <td colspan="3">
                                              <el-select v-model="addParam.input_chargeid" placeholder="请选择" clearable @change="hasChange" @dblclick.native="chooseChargeRule(1)" ref="input116" @keyup.enter.native="nextFocus(1, 16)" style="width: 100%;">
                                                  <el-option v-for="item in chargedataList" :key="item.chargeid" :label="item.chargename" :value="item.chargeid"></el-option>
                                              </el-select>
                                              <!-- <el-input v-model="addParam.input_chargeid" @input="hasChange" ref="input112" @keyup.enter.native="nextFocus(1, 12)" @dblclick.native="chooseChargeRule(1)"></el-input> -->
                                          </td>
                                          <td rowspan="4" width="30" class="text-note">双击维护特殊设置</td>
                                      </tr>
                                      <tr>
                                          <td align="right">标本编号规则</td>
                                          <td colspan="2">
                                              <el-input v-model="addParam.samplenorules" readonly @input="hasChange"></el-input>
                                          </td>
                                          <td>
                                              <el-button class="el-button--310" @click="mediumnoRule" v-has="'PDELETE'">向导</el-button>
                                          </td>
                                          <td align="right">培养阳性附加计费(一次性)</td>
                                          <td colspan="3">
                                              <el-select v-model="addParam.pos_chargeid" placeholder="请选择" clearable @change="hasChange" @dblclick.native="chooseChargeRule(2)" ref="input116" @keyup.enter.native="nextFocus(1, 16)" style="width: 100%;">
                                                  <el-option v-for="item in chargedataList" :key="item.chargeid" :label="item.chargename" :value="item.chargeid"></el-option>
                                              </el-select>
                                              <!-- <el-input v-model="addParam.pos_chargeid" @input="hasChange" ref="input113" @keyup.enter.native="nextFocus(1, 13)" @dblclick.native="chooseChargeRule(2)"></el-input> -->
                                          </td>
                                      </tr>
                                      <tr>
                                          <td align="right">示例</td>
                                          <td colspan="2">
                                              <el-input v-model="addParam.samplenoSample" disabled="disabled" @input="hasChange"></el-input>
                                          </td>
                                          <td></td>
                                          <td align="right">培养阳性附加计费(每培养基)</td>
                                          <td colspan="3">
                                              <el-select v-model="addParam.pospercul_chargeid" placeholder="请选择" clearable @change="hasChange" @dblclick.native="chooseChargeRule(3)" ref="input116" @keyup.enter.native="nextFocus(1, 16)" style="width: 100%;">
                                                  <el-option v-for="item in chargedataList" :key="item.chargeid" :label="item.chargename" :value="item.chargeid"></el-option>
                                              </el-select>
                                              <!-- <el-input v-model="addParam.pospercul_chargeid" @input="hasChange" @dblclick.native="chooseChargeRule(3)"></el-input> -->
                                          </td>
                                      </tr>
                                      <tr>
                                          <td align="right">报告小时数最少</td>
                                          <td>
                                              <el-input type="number" v-model="addParam.minreporthour" @input="hasChange" ref="input114" @keyup.enter.native="nextFocus(1, 14)"></el-input>
                                          </td>
                                          <td align="right">最大</td>
                                          <td>
                                              <el-input type="number" v-model="addParam.maxreporthour" @input="hasChange" ref="input115" @keyup.enter.native="nextFocus(1, 15)"></el-input>
                                          </td>
                                          <td align="right">初鉴报告附加计费</td>
                                          <td colspan="3">
                                              <el-select v-model="addParam.preeval_chargeid" placeholder="请选择" clearable @change="hasChange" @dblclick.native="chooseChargeRule(4)" ref="input116" @keyup.enter.native="nextFocus(1, 16)" style="width: 100%;">
                                                  <el-option v-for="item in chargedataList" :key="item.chargeid" :label="item.chargename" :value="item.chargeid"></el-option>
                                              </el-select>
                                          </td>
                                      </tr>
                                      <tr>
                                          <!-- <td align="right">允许重复登记</td>
                                          <td >
                                              <el-checkbox v-model="addParam.reacceptflag" true-label="1" false-label="0" @change="hasChange"></el-checkbox>
                                          </td> -->
                                          <td  width="140" align="right">不自动打印流程单</td>
                                          <td >
                                              <el-checkbox v-model="addParam.notprintproecssflag" true-label="1" false-label="0" @change="hasChange"></el-checkbox>
                                          </td>
                                          
                                          <td align="right">院感标识</td>
                                          <td >
                                              <el-checkbox v-model="addParam.ygflag" true-label="1" false-label="0" @change="hasChange"></el-checkbox>
                                          </td>
                                          <td width="220" align="right">检验工作组</td>
                                          <td colspan="3">
                                              <rm-ddl-common :appendtobody="true" datatype="labgroup" v-model="addParam.labgroupid" @change="hasChange" ref="input117" @keyup.enter.native="nextFocus(1, 17)" irrelevant="groupShowIrrelevant" style="width:100%"></rm-ddl-common>
                                          </td>
                                      </tr>
                                      <tr>
                                          
                                      </tr>
                                  </table>
                              </el-tab-pane>
                              <el-tab-pane label="标本类型">
                                  <div class="specimen-type">
                                      <vxe-table show-overflow ref="xTable2" :data.sync="bactDetailList" class="mytable-style" :loading="bactLoading" height="auto" width="100%" 
                                          :keyboard-local-config="keyLocalConfig" :mouse-config="{ selected: true }" highlight-current-row resizable stripe border size="mini" 
                                          @cell-dblclick="CellDblclick" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }">
                                          <vxe-table-column field="specimencode" title="标本类型" :edit-render="{name:'input'}" width="140px" header-align="center">
                                              <template v-slot:edit="{row, rowIndex}">
                                                  <!-- <rm-ddl-common :appendtobody="true" datatype="specimen" v-model="row.specimencode" @change="hasChange" ref="inputspec" style="width:100%"></rm-ddl-common> -->
                                                  <el-select v-model="row.specimencode" filterable placeholder="请选择" @dblclick.native="specimenDblclick(row)" @change="hasChange">
                                                      <!-- <el-select v-model="row.specimencode" filterable placeholder="请选择" @dblclick.native="specimenDblclick(row)" @change="hasChange"> -->
                                                      <el-option v-for="item in specimenOption" :key="rowIndex + item.value" :label="item.label" :value="item.value"></el-option>
                                                  </el-select>
                                              </template>
                                              <template v-slot="{row}">
                                                  <span>{{getShowName(row.specimencode, "specimenOption")}}</span>
                                              </template>
                                          </vxe-table-column>
                                          <vxe-table-column field="mediumgroupno" title="培养基组合" :edit-render="{name:'input'}" width="140px" header-align="center">
                                              <template v-slot:edit="{row}">
                                                  <el-select v-model="row.mediumgroupno" filterable placeholder="请选择" @change="hasChange" clearable>
                                                      <el-option v-for="item in mediumgroupList" :key="item.mediumgroupno" :label="item.label" :value="item.value"></el-option>
                                                  </el-select>
                                              </template>
                                              <template v-slot="{row}">
                                                  <span>{{getShowName(row.mediumgroupno, "mediumgroupList")}}</span>
                                              </template>
                                          </vxe-table-column>
                                          <!-- <vxe-table-column field="specimen_comm" title="默认标本备注" width="140px" :edit-render="{name: 'select',options:specimencommList, events: {change: (row,val) => {row.row.specimen_comm = val.target.value;hasChange()}}}" header-align="center"></vxe-table-column> -->
                                          <vxe-table-column field="specimen_comm" title="默认标本备注" width="140px" :edit-render="{name:'input'}" header-align="center">
                                              <template v-slot:edit="{row}">
                                                  <el-select v-model="row.specimen_comm" placeholder="请选择" @change="hasChange" clearable>
                                                      <el-option v-for="item in specimencommList" :key="item.data" :label="item.display" :value="item.data"></el-option>
                                                  </el-select>
                                              </template>
                                              <template v-slot="{row}">
                                                  <span>{{getShowName(row.specimen_comm, "specimencommList")}}</span>
                                              </template>
                                          </vxe-table-column>
                                          <vxe-table-column field="notprintproecssflag" title="不自动打印流程单"  width="120" align="center">
                                              <template v-slot="{ row }">
                                                  <el-checkbox v-model="row.notprintproecssflag" true-label="1" false-label="0" @change="hasChange"></el-checkbox>
                                                  <!-- <el-select ref="notprintproecssflag" v-model="row.notprintproecssflag" @change="hasChange" placeholder="请选择" >
                                                      <el-option value="1" label="是">是</el-option>
                                                      <el-option value="0" label="否">否</el-option>
                                                  </el-select> -->
                                              </template>
                                          </vxe-table-column>
                                          <vxe-table-column field="seq" title="序号" :edit-render="{name:'input', autoselect: true, events: {change: hasChange}}" width="50" align="center">
                                              <template v-slot:edit="{ row }">
                                                  <el-input v-model="row.seq" @change="hasChange"></el-input>
                                              </template>
                                          </vxe-table-column>
                                          <vxe-table-column field="minreporthour" title="报告最小小时数" :edit-render="{name:'input', autoselect: true}" width="60px" header-align="center">
                                              <template v-slot:edit="{ row }">
                                                  <el-input v-model="row.minreporthour" @change="hasChange"></el-input>
                                              </template>
                                          </vxe-table-column>
                                          <vxe-table-column field="maxreporthour" title="报告最大小时数" :edit-render="{name:'input', autoselect: true}" width="60px" header-align="center">
                                              <template v-slot:edit="{ row }">
                                                  <el-input v-model="row.maxreporthour" @change="hasChange"></el-input>
                                              </template>
                                          </vxe-table-column>
                                          <vxe-table-column field="exbarcount" title="附加条码数" :edit-render="{name:'input', autoselect: true}" width="50px" header-align="center">
                                              <template v-slot:edit="{ row }">
                                                  <el-input v-model="row.exbarcount" @change="hasChange"></el-input>
                                              </template>
                                          </vxe-table-column>
                                          <!-- <vxe-table-column field="samplenoSample" title="标本编号规则/示例(双击打开向导编辑)" width="130px" header-align="center"></vxe-table-column> -->
                                          <vxe-table-column field="samplenorules" title="标本编号规则(双击打开向导编辑)" width="120px" header-align="center">
                                              <template v-slot:header>
                                                  <div>标本编号规则</div>
                                                  <div>(双击打开向导编辑)</div>
                                              </template>
                                          </vxe-table-column>
                                          <vxe-table-column field="purposekind" title="检验目的归类" :edit-render="{name:'input'}" width="100px" header-align="center">
                                              <template v-slot:edit="{ row }">
                                                  <el-select v-model="row.purposekind" placeholder="请选择" @change="hasChange" style="width: 100%;">
                                                      <el-option v-for="item in pkList" :key="item.data" :label="item.display" :value="item.data"></el-option>
                                                  </el-select>
                                              </template>
                                              <template v-slot="{row}">
                                                  <span>{{getShowName(row.purposekind, "pkList")}}</span>
                                              </template>
                                          </vxe-table-column>
                                          <vxe-table-column field="definputmdl" title="阴性结果默认输入模板" :edit-render="{name:'input'}" width="100px" header-align="center">
                                              <template v-slot:edit="{ row }">
                                                  <el-select v-model="row.definputmdl" placeholder="请选择" @change="hasChange" style="width: 100%;">
                                                      <el-option v-for="item in dtmdlList" :key="item.inputmdlid" :label="item.mdlname" :value="item.inputmdlid"></el-option>
                                                  </el-select>
                                              </template>
                                              <template v-slot="{row}">
                                                  <span>{{getShowName(row.definputmdl, "dtmdlList")}}</span>
                                              </template>
                                          </vxe-table-column>
                                          <vxe-table-column field="input_chargeid" title="录入时附加计费" :edit-render="{name:'select',options: chargedataList, events: {change: hasChange}}" width="120px" header-align="center"></vxe-table-column>
                                          <vxe-table-column field="pos_chargeid" title="培养阳性附加计费(一次性)" :edit-render="{name:'select',options: chargedataList, events: {change: hasChange}}" width="110px" header-align="center"></vxe-table-column>
                                          <vxe-table-column field="pospercul_chargeid" title="培养阳性附加计费(每培养基)" :edit-render="{name:'select',options: chargedataList, events: {change: hasChange}}" width="110px" header-align="center"></vxe-table-column>
                                          <vxe-table-column field="preeval_chargeid" title="初鉴报告附加计费" :edit-render="{name:'select',options: chargedataList, events: {change: hasChange}}" width="120px" header-align="center"></vxe-table-column>
                                      </vxe-table>
                                  </div>
                                  <div class="detail-operation">
                                      <el-button icon="el-icon-plus" class="el-button--310" @click="MainOpenDialog(5)">新增明细</el-button>
                                      <el-button icon="el-icon-caret-top" class="el-button--310" @click="MainOpenDialog(6)">插入明细</el-button>
                                      <el-button icon="el-icon-delete" class="el-button--310" @click="MainOpenDialog(7)">删除明细</el-button>
                                      <el-button icon="el-icon-news" class="el-button--310" @click="MainOpenDialog(8)">复制</el-button>
                                      <el-button icon="el-icon-document" class="el-button--310" @click="MainOpenDialog(9)">粘贴</el-button>
                                  </div>
                              </el-tab-pane>
                              <el-tab-pane class="text-pane" label="备选培养基">
                                  <div class="specimen-type">
                                      <div class="bact">
                                          <vxe-table show-overflow ref="specbactTable" :data.sync="specbactList" class="bact-table" height="auto" :sort-config="{trigger: 'cell'}" :keyboard-local-config="keyLocalConfig" border resizable stripe highlight-current-row header-align="center" @current-change="currentChangeEvent1">
                                              <vxe-table-column field="specimen_name" title="可用标本种类" width="160">
                                                  <template v-slot="{ row }">
                                                      <span v-if="row.specimencode != 'All'">{{row.specimen_name}}</span>
                                                      <span v-else>默认</span>
                                                  </template>
                                              </vxe-table-column>
                                              <vxe-table-column field="cp_cnt" title="已对照数" width="120"></vxe-table-column>
                                          </vxe-table>
                                      </div>
                                      <div class="purpculresult">
                                          <vxe-table show-overflow ref="bactTable" :data.sync="specmediumgroupList" class="bact-table" height="auto" :sort-config="{trigger: 'cell'}" size="mini" :keyboard-local-config="keyLocalConfig" border highlight-current-row resizable stripe header-align="center" :row-class-name="rowClassName" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }">
                                              <vxe-table-column field="seq" title="序号" :edit-render="{name:'input', events: {change: hasChange}}" align="center" width="80"></vxe-table-column>
                                              <vxe-table-column field="mediumgroupno" title="培养基组合" :edit-render="{name:'input'}" width="180">
                                                  <template v-slot:edit="{row}">
                                                      <el-select v-model="row.mediumgroupno" filterable placeholder="请选择" @change="hasChange">
                                                          <el-option v-for="item in mediumgroupList" :key="item.mediumgroupno" :label="item.label" :value="item.value"></el-option>
                                                      </el-select>
                                                  </template>
                                                  <template v-slot="{row}">
                                                      <span>{{getShowName(row.mediumgroupno, "mediumgroupList")}}</span>
                                                  </template>
                                              </vxe-table-column>
                                          </vxe-table>
                                      </div>
                                  </div>
                                  <div class="detail-operation">
                                      <el-button icon="el-icon-plus" class="el-button--310" @click="MainOpenDialog(10)">新增明细</el-button>
                                      <el-button icon="el-icon-caret-top" class="el-button--310" @click="MainOpenDialog(11)">插入明细</el-button>
                                      <el-button icon="el-icon-delete" class="el-button--310" @click="MainOpenDialog(12)">删除明细</el-button>
                                  </div>
                              </el-tab-pane>
                              <el-tab-pane class="text-pane" label="培养结果">
                                  <div class="specimen-type">
                                      <div class="bact">
                                          <vxe-table show-overflow ref="specpurposeTable" :data.sync="specpurposeList" class="bact-table" height="auto" :sort-config="{trigger: 'cell'}" :keyboard-local-config="keyLocalConfig" border highlight-current-row resizable stripe header-align="center" @current-change="currentChangeEvent2">
                                              <vxe-table-column field="specimen_name" title="可用标本种类" width="160">
                                                  <template v-slot="{ row }">
                                                      <span v-if="row.specimencode != 'All'">{{row.specimen_name}}</span>
                                                      <span v-else>默认</span>
                                                  </template>
                                              </vxe-table-column>
                                              <vxe-table-column field="cp_cnt" title="已对照数" width="120"></vxe-table-column>
                                          </vxe-table>
                                      </div>
                                      <div class="purpculresult">
                                          <vxe-table show-overflow ref="purpculresultTable" :data.sync="purpculresultList" class="bact-table" height="auto" border resizable stripe 
                                              :sort-config="{trigger: 'cell'}" :keyboard-local-config="keyLocalConfig" highlight-current-row header-align="center" 
                                              :row-class-name="rowClassName" @cell-dblclick="culresultDblEvent" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }">
                                              <vxe-table-column field="seq" title="序号" :edit-render="{name: 'input', autoselect: true}" align="center" width="40">
                                                  <template v-slot:edit="{ row }">
                                                      <el-input v-model="row.seq" @change="hasChange"></el-input>
                                                  </template>
                                              </vxe-table-column>
                                              <vxe-table-column field="rpt_itemname" title="报告项目" :edit-render="{name: 'input'}" width="200">
                                                  <template v-slot:edit="{ row,rowIndex }">
                                                      <span v-if="row.reportid">{{row.rpt_itemname}}</span>
                                                      <el-input v-else @keyup.space.native="dialogRptVisible=true,$nextTick(() => {$refs.rptdialog.$refs.qcodeinput.focus();});" @keyup.down.native="ResultMove(row,1,rowIndex,'rpt_itemname')" @keyup.up.native="ResultMove(row,0,rowIndex,'rpt_itemname')" @change="rptitemInput(row)" v-model="row.rpt_itemname" style="width:100%;height:18px" :autofocus="true" ref="rptitemname"></el-input>
                                                  </template>
                                              </vxe-table-column>
                                              <vxe-table-column field="rpt_itemcode" title="报告项目代码" width="100"></vxe-table-column>
                                              <vxe-table-column v-if="showdefaultresultstr=='1'" field="defaultresult_str" title="默认结果" :edit-render="{name: 'input', autoselect: true}" width="150">
                                                  <template v-slot:edit="{ row }">
                                                      <el-input v-model="row.defaultresult_str" @change="hasChange"></el-input>
                                                  </template>
                                              </vxe-table-column>
                                              <vxe-table-column field="defaultneg" title="默认类型" align="center" width="100">
                                                  <!-- <template v-slot="{ row }">
                                                      <el-checkbox v-model="row.defaultneg" true-label="1" false-label="0" @change="hasChange"></el-checkbox>
                                                  </template> -->
                                                  <template v-slot="{row}">
                                                      <el-select v-model="row.defaultneg" placeholder="请选择" @change="hasChange">
                                                          <el-option v-for="item in defaultnegList" :key="item.value" :label="item.label" :value="item.value"></el-option>
                                                      </el-select>
                                                  </template>
                                              </vxe-table-column>
                                              <vxe-table-column field="bloodculture" title="血培养专用" align="center" width="80">
                                                  <template v-slot="{ row }">
                                                      <el-checkbox v-model="row.bloodculture" true-label="1" false-label="0" @change="hasChange"></el-checkbox>
                                                  </template>
                                              </vxe-table-column>
                                              <vxe-table-column field="germflag" title="细菌标志" width="120"></vxe-table-column>
                                          </vxe-table>
                                      </div>
                                      <div class="detail-operation">
                                          <el-button icon="el-icon-plus" class="el-button--310" @click="MainOpenDialog(13)">新增明细</el-button>
                                          <el-button icon="el-icon-caret-top" class="el-button--310" @click="MainOpenDialog(14)">插入明细</el-button>
                                          <el-button icon="el-icon-delete" class="el-button--310" @click="MainOpenDialog(15)">删除明细</el-button>
                                      </div>
                                  </div>
                              </el-tab-pane>
                              <el-tab-pane  class="text-pane" label="批输入模板">
                                  <div class="specimen-type">
                                      <div class="bact">
                                          <vxe-table show-overflow ref="imdlspecpurposeTable" :data.sync="imdlspecpurposeList" class="bact-table" height="auto" :sort-config="{trigger: 'cell'}"  :keyboard-local-config="keyLocalConfig" border highlight-current-row resizable stripe header-align="center" @current-change="currentChangeEvent3">
                                              <vxe-table-column field="specimen_name" title="可用标本种类" width="160">
                                                  <template v-slot="{ row }">
                                                      <span v-if="row.specimencode != 'All'">{{row.specimen_name}}</span>
                                                      <span v-else>默认</span>
                                                  </template>
                                              </vxe-table-column>
                                              <vxe-table-column field="cp_cnt" title="已对照数" width="120"></vxe-table-column>
                                          </vxe-table>
                                      </div>
                                      <div class="purpculresult">
                                          <vxe-table show-overflow ref="imdlpurposeTable" :data.sync="imdlpurposeList" class="bact-table" height="auto" :sort-config="{trigger: 'cell'}" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }" :keyboard-local-config="keyLocalConfig" border highlight-current-row resizable stripe header-align="center"  >
                                              <!-- <vxe-table-column field="seq" title="序号" width="50"></vxe-table-column>  -->
                                              <vxe-table-column field="seq" title="序号" :edit-render="{name: 'input', autoselect: true}" align="center" width="70">
                                                  <template v-slot:edit="{ row }">
                                                      <el-input v-model="row.seq" @change="hasChange"></el-input>
                                                  </template>
                                              </vxe-table-column>
                                              <vxe-table-column field="inputmdlid" title="模板ID" width="50"></vxe-table-column> 
                                              <vxe-table-column field="mdlname" title="模板名称" width="160">
                                                  <template v-slot="{ row }">
                                                      <rm-ddl-common dataname="批次输入模板"  @change="inputmdlchange" datatype="labinputmdl" v-model="row.inputmdlid" width="100%" :appendtobody="true"></rm-ddl-common>
                                                  </template>
                                              </vxe-table-column> 
                                              <!-- <vxe-table-column field="specimen_name" title="标本类型" width="160">
                                                  <template v-slot="{ row }">
                                                      <span v-if="row.specimen_code != 'All'">{{row.specimen_name}}</span>
                                                      <span v-else>默认</span>
                                                  </template>
                                              </vxe-table-column> -->
                                          </vxe-table>
                                      </div>
                                      <div class="detail-operation">
                                          <el-button icon="el-icon-plus" class="el-button--310" @click="MainOpenDialog(16)">新增模板</el-button>
                                          <el-button icon="el-icon-caret-top" class="el-button--310" @click="MainOpenDialog(17)">插入模板</el-button>
                                          <el-button icon="el-icon-delete" class="el-button--310" @click="MainOpenDialog(18)">删除模板</el-button>
                                      </div>
                                      <!-- <div class="purpculresult">
                                          <vxe-table show-overflow ref="purpinputmdltTable" :data.sync="purpinputmdltList" class="bact-table" height="auto" border resizable stripe 
                                              :sort-config="{trigger: 'cell'}" :keyboard-local-config="keyLocalConfig" highlight-current-row header-align="center" 
                                                 >
                                              <vxe-table-column field="seq" title="序号"  align="center" width="40">
                                              </vxe-table-column>
                                              <vxe-table-column field="rpt_itemname" title="报告项目" width="200">
                                              </vxe-table-column>
                                              <vxe-table-column field="rpt_itemcode" title="报告项目代码" width="120"></vxe-table-column>
                                              <vxe-table-column field="defaultval" title="默认值" width="120"></vxe-table-column>
                                              <vxe-table-column field="defaultresult1" title="结果1默认值" width="120"></vxe-table-column>
                                              <vxe-table-column field="defaultresult2" title="结果2默认值" width="120"></vxe-table-column>
                                              <vxe-table-column field="defaultresult3" title="结果3默认值" width="120"></vxe-table-column>
                                              <vxe-table-column field="defaultresult_txt" title="文字结果默认值" width="120"></vxe-table-column>
                                          </vxe-table>
                                      </div> -->
                                  </div>

                              </el-tab-pane>
                          </el-tabs>
                      </div>
                  </template>
              </rm-layout-right>
          </div>
      </div>
      <el-dialog width="700px"  v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="报告项目文字结果选择" :visible.sync="dialogResultVisible" v-if="dialogResultVisible" >
          <el-container style="border: 1px solid #eee;height:500px">
              <el-main style="overflow: hidden;padding:0 0">
                  <el-input @keyup.native="ResultSearchkeydown" placeholder="快速检索" prefix-icon="el-icon-search" ref="qcodeinput" style="width:300px;" v-model="Resultqcode"></el-input>
                  <el-button @click="Resultok" icon="el-icon-circle-check" style="margin-left:10px;">确定</el-button>
                  <el-button @click="Resultcancel" icon="el-icon-circle-close">取消</el-button>
                  <div style="height: 464px">
                      <vxe-table :data="tableDataResultS" @cell-dblclick="ResultSelect" border height="564px" highlight-current-row highlight-hover-row resizable size="mini" stripe style="margin-top:10px" ref="xTableResultAll">
                          <!-- <vxe-table-column :field="item.field" :key="item.field" :title="item.title" width="100px" v-for="item in tableColumnResultAll"></vxe-table-column> -->
                          <vxe-table-column field="textvalue" title="文字结果" width="310"></vxe-table-column>
                          <vxe-table-column field="inputcode" title="快速输入码" width="100"></vxe-table-column>
                          <vxe-table-column field="containtext" title="录入码" width="100"></vxe-table-column>
                          <vxe-table-column field="seq" title="序号" width="50"></vxe-table-column>
                      </vxe-table>
                  </div>
              </el-main>
          </el-container>
      </el-dialog>
      <el-dialog width="550px" top="10px" :append-to-body="true" :close-on-click-modal="false" title="标本编号规则向导" :visible.sync="dialogTableVisible" :destroy-on-close="true">
          <div>
              <table>
                  <tr>
                      <td align="right" width="100">组别前缀</td>
                      <td width="120">
                          <el-input v-model="mediumnoParam.matchnohead" disabled="disabled"></el-input>
                      </td>
                      <td></td>
                  </tr>
                  <tr>
                      <td align="right">日期6(或2)位前缀</td>
                      <td colspan="3">
                          <el-select v-model="mediumnoParam.no1" filterable placeholder="请选择" @change="mediumnoArea(1)" style="width: 100%;">
                              <el-option v-for="item in noList" :key="'no' + item.value" :label="item.name" :value="item.value"></el-option>
                          </el-select>
                      </td>
                      <td width="30"></td>
                      <td>
                          <el-button @click="sureRule">确定</el-button>
                      </td>
                  </tr>
                  <tr>
                      <td align="right">类别1位前缀</td>
                      <td>
                          <el-select v-model="mediumnoParam.no2" filterable placeholder="请选择" @change="mediumnoArea">
                              <el-option v-for="item in noList1" :key="'no1' + item" :label="item" :value="item"></el-option>
                          </el-select>
                      </td>
                      <td align="right" width="60">最小号</td>
                      <td>
                          <el-input type="number" v-model="mediumnoParam.no4" :min="0" :maxlength="mediumnoParam.no3" @input="mediumnoArea"></el-input>
                      </td>
                      <td></td>
                      <td>
                          <el-button @click="closeDialog">取消</el-button>
                      </td>
                  </tr>
                  <tr>
                      <td align="right">流水号长度</td>
                      <td>
                          <el-select v-model="mediumnoParam.no3" filterable placeholder="请选择" @change="mediumnoArea">
                              <el-option v-for="(item,idx) in noList2" :key="'no2' + idx" :label="item" :value="item"></el-option>
                          </el-select>
                      </td>
                      <td align="right">最大号</td>
                      <td>
                          <el-input type="number" v-model="mediumnoParam.no5" :maxlength="mediumnoParam.no3" @input="mediumnoArea"></el-input>
                      </td>
                      <td colspan="2"></td>
                  </tr>
                  <tr>
                      <td align="right">流水号循环</td>
                      <td>
                          <el-select v-model="mediumnoParam.no9" filterable placeholder="请选择" :disabled="typedisable" @change="mediumnoArea" style="width: 100%;">
                              <el-option  v-for="item in noList3" :key="'no9' + item.value" :label="item.name" :value="item.value"></el-option>
                          </el-select>
                      </td>
                  </tr>
                  <tr>
                      <td></td>
                      <td>
                          <el-checkbox v-model="mediumnoParam.no6" @change="mediumnoArea" style="margin: 15px 0 5px 0;"></el-checkbox> 类别放在日期之前
                      </td>
                  </tr>
                  <tr>
                      <td align="right">标本号取值示例</td>
                      <td colspan="4">
                          <el-input v-model="mediumnoParam.no7" disabled="disabled"></el-input>
                      </td>
                      <td width="100">
                          <el-input v-model="mediumnoParam.no8" disabled="disabled"></el-input>
                      </td>
                  </tr>
                  <tr>
                      <td colspan="6">提示：如果存在多院区多微生物组，可在程序MNG260中设定附加的标本号前缀以区分组别；尽量保证最终的标本号为偶数位，否则可能影响条码的识别率</td>
                  </tr>
              </table>
          </div>
      </el-dialog>
      <el-dialog width="1000px" top="10px" :append-to-body="true" :close-on-click-modal="false" title="选择标本类型" :visible.sync="specimenVisible" :destroy-on-close="true">
          <rm-pop-common @change="popcomchange" @cancel="specimenVisible=false;" :multiple="false" datatype="specimen"></rm-pop-common>
      </el-dialog>
      <el-dialog width="650px" top="10px" :append-to-body="true" :close-on-click-modal="false" :title="chargeruleTitle" :visible.sync="chargeruleVisible" :destroy-on-close="true">
          <div>
              <vxe-table show-overflow ref="xTable3" :data.sync="chargeRuleList" height="250px" width="100%" border size="mini" :keyboard-local-config="keyLocalConfig" :mouse-config="{ selected: true }" show-header-overflow highlight-current-row resizable stripe :edit-config="{ trigger: 'click', mode: 'row', showStatus: true, showIcon: false }">
                  <vxe-table-column field="req_deptno" title="申请科室" width="160px" header-align="center">
                      <template v-slot="{ row }">
                          <rm-ddl-common datatype="dept" dataname="申请科室" v-model="row.req_deptno" width="100%" :appendtobody="true" :readonly="true"></rm-ddl-common>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="definputmdl" title="默认输入模板" width="160px" header-align="center">
                      <template v-slot="{ row }">
                          <el-select v-model="row.definputmdl" filterable placeholder="请选择" @change="hasChange" style="width: 100%;">
                              <el-option v-for="item in dtmdlList" :key="item.inputmdlid" :label="item.mdlname" :value="item.inputmdlid"></el-option>
                          </el-select>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="purposename" title="检验目的" width="120px" header-align="center"></vxe-table-column>
                  <vxe-table-column field="specimen_name" title="标本类型" width="160px" header-align="center"></vxe-table-column>
                  <!-- <vxe-table-column field="create_stepname" title="计费节点" width="100px" header-align="center" v-if="chargeType == 2" :key="Math.random()"></vxe-table-column> -->
              </vxe-table>
              <div class="detail-operation">
                  <el-button icon="el-icon-plus" @click="chargeRuleDeal(1)">新增</el-button>
                  <el-button icon="el-icon-delete" @click="chargeRuleDeal(2)">删除</el-button>
                  <el-button icon="el-icon-document" @click="chargeRuleDeal(3)">保存</el-button>
                  <el-button icon="el-icon-close" @click="chargeRuleDeal(4)">取消</el-button>
              </div>
          </div>
      </el-dialog>
      <el-dialog width="650px" top="10px" :append-to-body="true" :close-on-click-modal="false" :title="chargeruleTitle" :visible.sync="chargeruleVisible2" :destroy-on-close="true">
          <div>
              <vxe-table show-overflow ref="xTable4" :data.sync="chargeRuleList" height="250px" width="100%" border size="mini" :keyboard-local-config="keyLocalConfig" :mouse-config="{ selected: true }" show-header-overflow highlight-current-row resizable stripe :edit-config="{ trigger: 'click', mode: 'row', showStatus: true, showIcon: false }">
                  <vxe-table-column field="req_deptno" title="申请科室" width="160px" header-align="center">
                      <template v-slot="{ row }">
                          <rm-ddl-common datatype="dept" dataname="申请科室" v-model="row.req_deptno" width="100%" :appendtobody="true" :readonly="true"></rm-ddl-common>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="purposename" title="检验目的" width="140px" header-align="center"></vxe-table-column>
                  <vxe-table-column field="specimen_name" title="标本类型" width="160px" header-align="center"></vxe-table-column>
                  <vxe-table-column field="create_step1" title="计费节点" width="100px" header-align="center"></vxe-table-column>
              </vxe-table>
              <div class="detail-operation">
                  <el-button icon="el-icon-plus" @click="chargeRuleDeal(1)" v-has="'PADD'">新增</el-button>
                  <el-button icon="el-icon-delete" @click="chargeRuleDeal(2)" v-has="'PDELETE'">删除</el-button>
                  <el-button icon="el-icon-document" @click="chargeRuleDeal(3)" v-has="'PDELETE'">保存</el-button>
                  <el-button icon="el-icon-close" @click="chargeRuleDeal(4)" v-has="'PDELETE'">取消</el-button>
              </div>
          </div>
      </el-dialog>
      <el-dialog width="900px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="报告项目" :visible.sync="dialogRptVisible" @close="$refs.purpculresultTable.setActiveCell($refs.purpculresultTable.getCurrentRow(), 'rpt_itemname')">
          <rm-pop-rptitem class="pop-content-table" prgno="LIS835" @cancel="dialogRptVisible=false,$refs.purpculresultTable.setActiveCell($refs.purpculresultTable.getCurrentRow(), 'rpt_itemname')" :isAllRpt="1" :rptunitdisabled="true" :germmode="true" :initgermflag="1" @selitem="addrptitem" ref="rptdialog"></rm-pop-rptitem>
      </el-dialog>
  </div>
</template>

<script>
import XEUtils from "xe-utils";
import axios from "axios";
import BacCommon from "@/components/common/baccommon"; 
export default {
  name: "LIS835",
  data() {
      return {
          glist: [],
          keyLocalConfig: {
              isArrow: true,
          },
          searchParam: {},
          barcode:"",
          bactPurposeList: [],
          fbactPurposeList: [],
          bactPurposeLoading: false,
          selrow: {},
          addParam: {}, // 新增 修改 字段
          faddParam: {},
          operatetype: 2, //1:新增 2:修改 3:删除
          changeflag: false,
          bactDetailList: [],
          bactLoading: false,
          detailrow: {},
          // mediumSpecLoading: false,
          allpurposenoList: [],
          activeName: "baseinfo",
          mediumgroupList: [],
          mediumgroupListMap: [],
          smearflagList: [
              { name: "无涂片", value: "" },
              { name: "涂片", value: "1" },
              { name: "培养+涂片", value: "2" },
          ],
          defaultnegList: [
              { label: " ", value: "0" },
              { label: "默认结果", value: "1" },
              { label: "默认培养", value: "2" },
          ],
          dialogTableVisible: false,
          specimenVisible: false,
          specimencommList: [],
          specimencommListMap: [],
          specimenOption: [],
          specimenOptionMap: [],
          dtmdlList: [],
          dtmdlListMap: [],
          pkList: [],
          pkListMap: [],
          chargedataList: [],
          noList: [
              { name: "D 年月日6位", value: "D" },
              { name: "# 年月日6位，流水号按月循环", value: "#" },
              { name: "$ 年月4位", value: "$" },
              { name: "Y 年份后2位", value: "Y" },
              { name: "空", value: "" },
          ],
          noList1: ["空", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Z"],
          noList2: [2, 3, 4, 5, 6, 7, 8, 9],
          noList3:[
              { name:"按年循环",value:"Y" },
              { name:"按月循环",value:"M" },
              { name:"按周循环",value:"W" },
              { name:"按日循环",value:"D" },
              { name:"无限循环",value:"" },
          ],
          noList3_D:[
              { name:"按年循环",value:"Y" },
              { name:"按月循环",value:"M" },
              { name:"按周循环",value:"W" },
              { name:"按日循环",value:"D" },
              { name:"无限循环",value:"" },
          ],
          noList3_M:[
              { name:"按年循环",value:"Y" },
              { name:"按月循环",value:"M" },
              { name:"无限循环",value:"" },
          ],
          noList3_Y:[
              { name:"按年循环",value:"Y" },
              { name:"无限循环",value:"" },
          ],
          typedisable:false,
          mediumnoParam: {
              no1: "D",
              no2: "空",
              no3: "3",
              no6: false,
              no8: "D3",
              no9: "空",
          },
          copyDetail: [],
          chargeruleTitle: "自动计价特殊规则",
          chargeruleVisible: false,
          chargeruleVisible2: false,
          chargeRuleList: [],
          chargeType: 1,
          curCreateStep: "",
          curCreateStepList: [
              { name: "核收录入", value: "1" },
              { name: "培养阳性", value: "2" },
              { name: "培养阳性", value: "3" },
              { name: "初鉴报告", value: "4" },
          ],
          specbactList: [],
          specbactRow: {},
          specmediumgroupList: [],
          fallSpecmediumgroupList: [],
          allSpecmediumgroupList: [],
          insertRecordsList1: [],
          removeRecordsList1: [],
          updateRecordsList1: [],
          specpurposeList: [],
          specpurposeRow: {},
          purpculresultList: [],
          fallPurpculresultList: [],
          allPurpculresultList: [],
          insertRecordsList2: [],
          removeRecordsList2: [],
          updateRecordsList2: [],

          imdlspecpurposeList:[],
          imdlspecpurposeRow:{},
          imdlpurposeList:[],
          allimdlpurposeList:[],
          insertRecordsList3: [],
          removeRecordsList3: [],
          updateRecordsList3: [],
          purpinputmdltList:[],

          dialogRptVisible: false,
          ddlData: [],
          form: {},
          showFile: false,
          url: "",
          updata: { action: "BACCOMMOMUPLOAD" }, 
          showdefaultresultstr:"0",

          tableColumnResultAll: [],
          tableDataResultAll:[],
          tableDataResultS: [],
          dialogResultVisible:false,
          Resultqcode:""

      };
  },
  mounted() {
      this.url = this.$tool.baseUrl.replace(/api/, "z") + "fileupload";
      this.initLabgroup();
      this.queryList();
      this.queryBactPurpose();
  },
  methods: {
      initLabgroup() {
          BacCommon.initLabgroup(this, "initData");
      },
      initData() {
          this.queryBactPurpose();
      },
      // 查询组合
      queryList() {
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS835",
                  method: "post",
                  data: {
                      action: "querylist",
                  },
              })
              .then((response) => {
                  if (response.errcode == 1) {
                      this.mediumgroupList = response.mediumgrouplist;
                      this.mediumgroupListMap = this.$pub.arrayToMap(this.mediumgroupList, "value", "label");
                      this.specimenOption = response.specimenlist;
                      this.specimenOptionMap = this.$pub.arrayToMap(this.specimenOption, "value", "label");
                      this.specimencommList = response.specimencommlist;
                      this.specimencommListMap = this.$pub.arrayToMap(this.specimencommList, "data", "display");
                      this.chargedataList = response.chargedata;
                      this.dtmdlList = response.dtmdl ? response.dtmdl : [];
                      this.dtmdlListMap = this.$pub.arrayToMap(this.dtmdlList, "value", "label");
                      this.pkList = response.pklist;
                      this.pkListMap = this.$pub.arrayToMap(this.pkList, "data", "display");
                      this.mediumnoParam.matchnohead = response.defid.matchnohead;
                      this.showdefaultresultstr = response.showdefaultresultstr;
                  }
              })
              .catch((e) => {});
      },
      queryBactPurpose() {
          this.bactPurposeLoading = true;
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS835",
                  method: "post",
                  data: {
                      action: "querybactpurpose",
                      labgroupid:this.searchParam.labgroupid,
                      glist:this.glist,
                  },
              })
              .then((response) => {
                  this.bactPurposeLoading = false;
                  if (response.errcode == 1) {
                      if (response.Data.length > 0) {
                          var purposenoList = [];
                          response.Data.forEach((element) => {
                              purposenoList.push(element.purposeno);
                              element.updateflag = 0;
                          });
                          this.fbactPurposeList = XEUtils.clone(response.Data, true);
                          this.bactPurposeList = response.Data;
                          // this.faddParam = XEUtils.clone(response[0], true);
                          // this.addParam = XEUtils.clone(response[0], true);
                          this.allpurposenoList = purposenoList;
                          this.selrow = response.Data[0];
                          this.$refs.xTable.setCurrentRow(this.selrow);
                          this.queryBactDetail(this.selrow.purposeno);
                      } else {
                          this.bactPurposeList = [];
                      }
                  }
              })
              .catch((e) => {});
      },
      queryBactDetail(purposeno) {
          this.bactLoading = true;
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS835",
                  method: "post",
                  data: {
                      action: "querydetail",
                      purposeno: purposeno,
                  },
              })
              .then((response) => {
                  this.bactLoading = false;
                  if (response.group.length > 0) {
                      // this.dealMediumno(response.group[0].samplenorules);
                      // response.group[0].samplenoSample = this.addParam.samplenoSample;
                      // response.group[0].samplenoSample = this.dealMediumno(response.group[0].samplenorules);
                      this.faddParam = XEUtils.clone(response.group[0], true);
                      this.addParam = response.group[0];
                      // console.log(this.addParam)
                  }
                  if (response.details.length > 0) {
                      this.bactDetailList = response.details;
                      this.$refs.xTable2.setCurrentRow(response.details[0]);
                  } else {
                      this.bactDetailList = [];
                  }
                  this.specbactList = response.specpurpose1;
                  if (this.specbactList.length > 0) {
                      this.specbactRow = this.specbactList[0];
                      this.$refs.specbactTable.setCurrentRow(this.specbactRow);
                  }
                  this.fallSpecmediumgroupList = XEUtils.clone(response.data1, true);
                  this.allSpecmediumgroupList = XEUtils.clone(response.data1, true);
                  this.specmediumgroupList = response.data1.filter((item) => item.specimencode == "All");

                  this.specpurposeList = response.specpurpose;
                  if (this.specpurposeList.length > 0) {
                      this.specpurposeRow = this.specpurposeList[0];
                      this.$refs.specpurposeTable.setCurrentRow(this.specpurposeRow);
                  }
                  this.fallPurpculresultList = XEUtils.clone(response.purpculresult, true);
                  this.allPurpculresultList = XEUtils.clone(response.purpculresult, true);
                  this.purpculresultList = response.purpculresult.filter((item) => item.specimencode == "All");

                  this.imdlspecpurposeList=response.imdlspecpurpose;
                  if(this.imdlspecpurposeList.length > 0){
                      this.imdlspecpurposeRow=this.imdlspecpurposeList[0];
                      this.$refs.imdlspecpurposeTable.setCurrentRow(this.imdlspecpurposeRow);
                  }
                  this.allimdlpurposeList=XEUtils.clone(response.imdlpurposeresult,true); 
                  this.imdlpurposeList=response.imdlpurposeresult.filter((item)=>item.specimencode=="All");

              })
              .catch((e) => {});
      },
      // getimdldetail(imdlid){
      //     if(imdlid){
      //         this.$tool
      //             .request({
      //                 url: "LIS/LIS8/LIS835",
      //                 method: "post",
      //                 data: {
      //                     action: "imdldetail",
      //                     inputmdlid: imdlid,
      //                 },
      //             }).then((res)=>{
      //                 if(res.imdldetail.length>0){
      //                     this.purpinputmdltList=res.imdldetail;
      //                 }else{
      //                     this.purpinputmdltList=[];
      //                 }
      //             })
      //     } 
      // },
      filterData() {
          if (!this.barcode) {
              this.bactPurposeList = XEUtils.clone(this.fbactPurposeList, true);
              if (this.bactPurposeList.length > 0) {
                  this.$refs.xTable.setCurrentRow(this.bactPurposeList[0]);
                  this.queryBactDetail(this.bactPurposeList[0].purposeno);
                  this.selrow = this.$refs.xTable.getCurrentRow();
              }
          } else {
              let filterName = this.barcode.trim();
              if (filterName) {
                  let queryList = this.fbactPurposeList.filter((item) => item.purposeno.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || item.purposename.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || item.inputcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || item.labgroupname.toUpperCase().indexOf(filterName.toUpperCase()) > -1);
                  this.bactPurposeList = queryList;
                  if (queryList.length > 0) {
                      this.$refs.xTable.setCurrentRow(queryList[0]);
                      this.queryBactDetail(queryList[0].purposeno);
                      this.selrow = this.$refs.xTable.getCurrentRow();
                  } else {
                      this.addParam = [];
                      this.clearAllData();
                  }
              } else {
                  this.bactPurposeList = XEUtils.clone(this.fbactPurposeList, true);
                  if (this.bactPurposeList.length > 0) {
                      this.$refs.xTable.setCurrentRow(this.bactPurposeList[0]);
                      this.queryBactDetail(this.bactPurposeList[0].purposeno);
                      this.selrow = this.$refs.xTable.getCurrentRow();
                  }
              }
          }
      },
      currentChangeEvent(e) {
          if (this.changeflag) {
              // 点击切换之前的 row
              this.$refs.xTable.setCurrentRow(this.selrow);
              return false;
          }
          this.selrow = e.row;
          this.queryBactDetail(this.selrow.purposeno);
      },
      currentChangeEvent1(e) {
          var row = e.row;
          this.specbactRow = e.row;
          if (this.$refs.bactTable.tableFullData.length > 0) {
              var fspecimencode = this.$refs.bactTable.tableFullData[0].specimencode;
              this.allSpecmediumgroupList = this.allSpecmediumgroupList.filter((item) => item.specimencode != fspecimencode);
              if (this.$refs.bactTable.tableFullData.length > 0) this.allSpecmediumgroupList = this.allSpecmediumgroupList.concat(this.$refs.bactTable.tableFullData);
          }
          this.specmediumgroupList = this.allSpecmediumgroupList.filter((item) => item.specimencode == row.specimencode);
          this.getAllList(1);
      },
      currentChangeEvent2(e) {
          var row = e.row;
          this.specpurposeRow = e.row;
          if (this.$refs.purpculresultTable.tableFullData.length > 0) {
              var fspecimencode = this.$refs.purpculresultTable.tableFullData[0].specimencode;
              this.allPurpculresultList = this.allPurpculresultList.filter((item) => item.specimencode != fspecimencode);
              if (this.$refs.purpculresultTable.tableFullData.length > 0) this.allPurpculresultList = this.allPurpculresultList.concat(this.$refs.purpculresultTable.tableFullData);
          }
          this.purpculresultList = this.allPurpculresultList.filter((item) => item.specimencode == row.specimencode);
          this.getAllList(2);
      },
      currentChangeEvent3(e){
          var row=e.row;
          this.imdlspecpurposeRow=e.row;
          if(this.$refs.imdlpurposeTable.tableFullData.length>0){
              var fspecimencode = this.$refs.imdlpurposeTable.tableFullData[0].specimencode;
              this.allimdlpurposeList = this.allimdlpurposeList.filter((item) => item.specimencode != fspecimencode);
              if (this.$refs.imdlpurposeTable.tableFullData.length > 0) this.allimdlpurposeList = this.allimdlpurposeList.concat(this.$refs.imdlpurposeTable.tableFullData);
          }
          this.imdlpurposeList = this.allimdlpurposeList.filter((item) => item.specimencode == row.specimencode);
          this.getAllList(3);
      },
      inputmdlchange(c,n,row){
          var currentrow=this.$refs.imdlpurposeTable.getCurrentRow();
          var index=this.$refs.imdlpurposeTable.getRowIndex(currentrow);
          if(this.$refs.imdlpurposeTable.tableFullData.length > 1){
              var fulldata=XEUtils.clone(this.$refs.imdlpurposeTable.tableFullData,true);
              fulldata.splice(index,1);
              var hasrow = fulldata.find((item) => item.inputmdlid == c);
              if(hasrow){
                  this.$confirm("不能选择重复的模板", "提示", {
                      confirmButtonText: "确定",
                      cancelButtonText: "取消",
                      showCancelButton:false,
                      type: "warning",
                  }).then(()=>{
                      
                  }).catch(()=>{
                      this.$refs.imdlpurposeTable.setActiveCell(currentrow, "mdlname").then(() => {
                          if (this.$refs.mdlname) {
                              this.$refs.mdlname.focus();
                          }
                      });
                  })
                  currentrow.inputmdlid="";
                  currentrow.mdlname="";
                  this.hasChange();
              }else{
                  currentrow.inputmdlid=c;
                  currentrow.mdlname=n;
                  this.hasChange();
              }
          }else{
              currentrow.inputmdlid=c;
              currentrow.mdlname=n;
              this.hasChange();
          }
      },
      rowClassName({ row, rowIndex }) {
          if (row.updateflag == 1) {
              return "row-modify row--current";
          }
          if (row.updateflag == 2) {
              console.log("row-new row--current");
              return "row-new row--current";
          }
      },
      selectBlur(e) {
          this.addParam.specimen_comm = e.target.value;
          this.hasChange();
      },
      selectBlur1(e) {
          var value = e.target.value;
          this.addParam.purposekind = value;
          this.hasChange();
      },
      hasChange(type) {
          this.changeflag = true;
          if (type == 1) {
              this.addParam.inputcode = this.$pub.CreateInputcode(this.addParam.purposename, this).substring(0, 20);
          }
      },
      getShowName(code, list) {
          return this[list + "Map"].get(code);
      },
      specimenDblclick(row) {
          this.detailrow = row;
          this.specimenVisible = true;
          // this.changeflag = true;
      },
      popcomchange(c, v) {
          this.detailrow.specimencode = c;
          this.detailrow.specimenname = v;
          this.specimenVisible = false;
      },
      // mediumgroupChange(row) {
      //     console.log(this.mediumgroupList)
      //     console.log(row)
      //     this.hasChange();
      // },
      clearAllData() {
          this.mediumResultList = [];
          this.bactDetailList = [];
          this.specbactList = [];
          this.fallSpecmediumgroupList = [];
          this.allSpecmediumgroupList = [];
          this.specmediumgroupList = [];
          this.specpurposeList = [];
          this.fallPurpculresultList = [];
          this.allPurpculresultList = [];
          this.purpculresultList = [];
          this.copyDetail = [];
          this.insertRecordsList1 = [];
          this.removeRecordsList1 = [];
          this.insertRecordsList2 = [];
          this.removeRecordsList2 = [];
          this.insertRecordsList3 = [];
          this.removeRecordsList3 = [];
          this.imdlspecpurposeList=[];
          this.imdlpurposeList=[];
          this.allimdlpurposeList=[];
      },
      MainOpenDialog(type) {
          var that = this;
          switch (type) {
              case 1: // 新增
                  that.operatetype = 1;
                  that.hasChange();
                  that.activeName = "baseinfo";
                  that.addParam = {
                      bloodculture: 0,
                      samplenorules: "D3",
                  };
                  that.clearAllData();
                  setTimeout(() => {
                      that.$refs.input11.$refs.input.focus();
                  }, 100);
                  break;
              case 2: // 删除
                  that.$confirm("你确定删除这条记录?", "提示", {
                      confirmButtonText: "确定",
                      cancelButtonText: "取消",
                      type: "warning",
                  }).then(() => {
                      that.operatetype = 3;
                      that.saveData().then((response) => {
                          if (response.errcode != "1") {
                              that.$message({
                                  message: "保存失败！" + response.errmsg,
                                  type: "warning",
                              });
                          } else {
                              that.$message({
                                  message: "删除成功！",
                                  type: "success",
                              });
                              // that.QueryGroupSearch();
                              that.changeflag = false;
                              that.operatetype = 2;
                              // 删除不刷新表格
                              var delrow = this.$refs.xTable.getCurrentRow();
                              var rowindex = this.$refs.xTable.getTableData().fullData.indexOf(delrow);
                              this.bactPurposeList.splice(rowindex, 1);
                              this.$refs.xTable.loadData(this.bactPurposeList).then(() => {
                                  var havedata = this.$refs.xTable.getTableData().fullData;
                                  if (havedata.length > 0) {
                                      if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                                      this.fbactPurposeList = XEUtils.clone(havedata, true);
                                      this.faddParam = XEUtils.clone(havedata[rowindex], true);
                                      this.addParam = XEUtils.clone(havedata[rowindex], true);
                                      let selectrow = havedata[rowindex];
                                      this.$refs.xTable.setCurrentRow(selectrow);
                                      this.selrow = this.$refs.xTable.getCurrentRow();
                                      this.queryBactDetail(selectrow.purposeno);
                                  }
                              });
                              if (this.allpurposenoList.indexOf(delrow.purposeno) != -1) {
                                  this.allpurposenoList.splice(this.allpurposenoList.indexOf(delrow.purposeno), 1);
                              }
                          }
                      });
                  });
                  break;
              case 3: // 保存
                  that.SaveAllData();
                  break;
              case 4: // 取消
                  that.$confirm("确定取消当前修改?", "提示", {
                      confirmButtonText: "确定",
                      cancelButtonText: "取消",
                      type: "warning",
                  }).then(() => {
                      // if (that.operatetype == 1) {
                      //     that.mediumResultList = [];
                      // } else {
                      that.queryBactDetail(that.selrow.purposeno);
                      // }
                      that.operatetype = 2;
                      that.changeflag = false;
                      // that.addParam = XEUtils.clone(that.faddParam, true);
                      that.$nextTick(() => {
                          that.$refs.xTable.setCurrentRow(that.selrow);
                      });
                  });
                  break;
              case 5:
                  that.$refs.xTable2
                      .insert({
                          ...that.addParam,
                          seq: that.$refs.xTable2.tableFullData.length > 0 ? (Math.floor(that.$refs.xTable2.tableFullData[that.$refs.xTable2.tableFullData.length - 1].seq / 10) + 1) * 10 : 10,
                      })
                      .then(({ row }) => {
                          that.$nextTick(() => {
                              that.$refs.xTable2.setCurrentRow(row);
                          });
                      });
                  that.hasChange();
                  break;
              case 6:
                  that.mediumDetailTableInsert(1);
                  break;
              case 7:
                  that.mediumDetailTableDelete("xTable2");
                  break;
              case 8:
                  that.copyDetail = that.$refs.xTable2.tableFullData;
                  break;
              case 9:
                  if (that.copyDetail.length == 0) return false;
                  if (that.$refs.xTable2.tableFullData.length == 0) {
                      that.$refs.xTable2.insert(that.copyDetail);
                      that.hasChange();
                  } else {
                      var queryList = [];
                      that.copyDetail.forEach((item) => {
                          var haveflag = true;
                          that.$refs.xTable2.tableFullData.forEach((element) => {
                              if (element.specimencode.indexOf(item.specimencode) > -1 && element.mediumgroupno.indexOf(item.mediumgroupno) > -1) {
                                  haveflag = false;
                                  return false;
                              }
                          });
                          if (haveflag) {
                              queryList.push(item);
                          }
                      });
                      // console.log(queryList)
                      if (queryList.length > 0) {
                          that.$refs.xTable2.insert(queryList);
                          that.hasChange();
                      }
                  }
                  break;
              case 10:
                  if (!that.specbactRow.specimencode) {
                      that.$message.error("请先选择对应标本种类！");
                      return false;
                  }
                  that.$refs.bactTable
                      .insert({
                          purposeno: that.addParam.purposeno,
                          seq: that.$refs.bactTable.tableFullData.length > 0 ? (Math.floor(that.$refs.bactTable.tableFullData[that.$refs.bactTable.tableFullData.length - 1].seq / 10) + 1) * 10 : 10,
                          specimencode: that.specbactRow.specimencode,
                      })
                      .then(({ row }) => {
                          that.$nextTick(() => {
                              that.$refs.bactTable.setCurrentRow(row);
                          });
                      });
                  that.hasChange();
                  break;
              case 11:
                  that.mediumDetailTableInsert(2);
                  break;
              case 12:
                  that.mediumDetailTableDelete("bactTable");
                  break;
              case 13:
                  if (!that.specpurposeRow.specimencode) {
                      that.$message.error("请先选择对应标本种类！");
                      return false;
                  }
                  that.$refs.purpculresultTable
                      .insert({
                          purposeno: that.addParam.purposeno,
                          seq: that.$refs.purpculresultTable.tableFullData.length > 0 ? (Math.floor(that.$refs.purpculresultTable.tableFullData[this.$refs.purpculresultTable.tableFullData.length - 1].seq / 10) + 1) * 10 : 10,
                          specimencode: that.specpurposeRow.specimencode,
                      })
                      .then(({ row }) => {
                          that.$nextTick(() => {
                              that.$refs.purpculresultTable.setCurrentRow(row);
                          });
                      });
                  that.hasChange();
                  break;
              case 14:
                  if (!that.specpurposeRow.specimencode) {
                      that.$message.error("请先选择对应标本种类！");
                  } else {
                      that.mediumDetailTableInsert(3);
                  }
                  break;
              case 15:
                  that.mediumDetailTableDelete("purpculresultTable");
                  break;
              case 16:
                  if (!that.imdlspecpurposeRow.specimencode) {
                      that.$message.error("请先选择对应标本种类！");
                      return false;
                  }
                  that.$refs.imdlpurposeTable.insert({
                      purposeno: that.addParam.purposeno,
                      seq: that.$refs.imdlpurposeTable.tableFullData.length > 0 ? (Math.floor(that.$refs.imdlpurposeTable.tableFullData[this.$refs.imdlpurposeTable.tableFullData.length - 1].seq / 10) + 1) * 10 : 10,
                      specimencode: that.imdlspecpurposeRow.specimencode,
                  })
                  .then(({ row }) => {
                          that.$nextTick(() => {
                              that.$refs.imdlpurposeTable.setCurrentRow(row);
                          });
                      });
                  that.hasChange();
                  break;
              case 17:
                  if (!that.imdlspecpurposeRow.specimencode) {
                      that.$message.error("请先选择对应标本种类！");
                  } else {
                      that.mediumDetailTableInsert(4);
                  }
                  break;
              case 18:
                  that.mediumDetailTableDelete("imdlpurposeTable");
                  break;
          }
      },
      SaveAllData() {
          var that = this;
          if (that.addParam.purposeno == undefined || that.addParam.purposeno == "") {
              that.$alert("请输入检验目的代码", "信息", {
                  confirmButtonText: "确定",
                  callback: (action) => {},
              });
              return false;
          }
          if (that.addParam.purposename == undefined || that.addParam.purposename == "") {
              that.$alert("请输入检验目的名称", "信息", {
                  confirmButtonText: "确定",
                  callback: (action) => {},
              });
              return false;
          }
          if (that.operatetype == 1 && that.allpurposenoList.length > 0 && that.allpurposenoList.indexOf(that.addParam.purposeno) != -1) {
              that.$message({
                  message: "检验目的代码冲突",
                  type: "warning",
              });
              return false;
          }
          // 排序
          that.$refs.xTable2.tableFullData.sort((a, b) => {
              return a.seq - b.seq;
          });
          that.$refs.xTable2.tableFullData.forEach((element, index) => {
              element.seq = (index + 1) * 10;
          });
          // 保存
          that.operatetype = that.operatetype == 1 ? 1 : 2;
          if (that.$refs.specbactTable.getCurrentRow()) {
              // 备选培养基
              let specimencode = that.$refs.specbactTable.getCurrentRow().specimencode;
              // that.allSpecmediumgroupList = that.allSpecmediumgroupList.filter(item => item.specimencode != specimencode);
              // that.allSpecmediumgroupList = that.allSpecmediumgroupList.concat(that.$refs.bactTable.tableFullData);
              that.getAllList(1);
          }
          if (that.$refs.specpurposeTable.getCurrentRow()) {
              // 培养结果
              let specimencode1 = that.$refs.specpurposeTable.getCurrentRow().specimencode;
              // that.allPurpculresultList = that.allPurpculresultList.filter(item => item.specimencode != specimencode1);
              // that.allPurpculresultList = that.allPurpculresultList.concat(that.$refs.purpculresultTable.tableFullData);
              that.getAllList(2);
          }
          if(that.$refs.imdlspecpurposeTable.getCurrentRow()){
              //批输入模板
              that.getAllList(3);
          }
          that.saveData().then((response) => {
              if (response.errcode != "1") {
                  that.$message({
                      message: "保存失败！" + response.errmsg,
                      type: "warning",
                  });
              } else {
                  that.$message({
                      message: "保存成功！",
                      type: "success",
                  });
                  that.insertRecordsList1 = [];
                  that.removeRecordsList1 = [];
                  that.insertRecordsList2 = [];
                  that.removeRecordsList2 = [];
                  that.insertRecordsList3 = [];
                  that.removeRecordsList3 = [];
                  // this.queryMediumDetail(this.addParam.mediumno);
                  that.changeflag = false;
                  if (that.operatetype == 1) {
                      that.operatetype = 2;
                      that.$tool
                          .request({
                              url: "LIS/LIS8/LIS835",
                              method: "post",
                              data: {
                                  action: "querydetail",
                                  purposeno: that.addParam.purposeno,
                              },
                          })
                          .then((response) => {
                              that.mediumResultLoading = false;
                              response.group.updateflag = 2;
                              that.faddParam = XEUtils.clone(response.group[0], true);
                              that.addParam = response.group[0];
                              that.mediumResultList = response.details;
                              // 新增不更新表格操作
                              that.fbactPurposeList.push(response.group[0]);
                              that.bactPurposeList.push(response.group[0]);
                              that.$refs.xTable.loadData(that.bactPurposeList).then(() => {
                                  var lastrow = that.$refs.xTable.tableFullData[that.$refs.xTable.tableFullData.length - 1];
                                  that.$refs.xTable.setCurrentRow(lastrow).then(() => {
                                      that.selrow = that.$refs.xTable.getCurrentRow();
                                  });
                              });
                              that.allpurposenoList.push(that.addParam.purposeno);
                              that.queryBactDetail(that.addParam.purposeno);
                          })
                          .catch((e) => {});
                      return false;
                  }
                  if (that.operatetype == 2) {
                      that.queryBactDetail(that.addParam.purposeno);
                      var fcurbact = that.fbactPurposeList.find((t) => t.purposeno == that.selrow.purposeno);
                      that.addParam.updateflag = 1;
                      Object.keys(that.addParam).forEach((key) => {
                          if (that.selrow.hasOwnProperty(key)) {
                              that.selrow[key] = that.addParam[key];
                              if (fcurbact) {
                                  fcurbact[key] = that.addParam[key];
                              }
                          }
                      });
                      that.faddParam = XEUtils.clone(that.addParam, true);
                  }
                  that.operatetype = 2;
              }
          });
      },
      saveData() {
          var response = this.$tool.request({
              url: "LIS/LIS8/LIS835",
              method: "post",
              data: {
                  action: "savedata",
                  utype: this.operatetype,
                  purposeno: this.addParam.purposeno,
                  purposestr: this.addParam,
                  specmediumgroup: this.$refs.xTable2.getRecordset(),
                  // mediumgroup1str: that.allSpecmediumgroupList,
                  // purpculresult: that.allPurpculresultList,
                  mediumgroup1str: {
                      insertRecords: this.insertRecordsList1,
                      removeRecords: this.removeRecordsList1,
                      // updateRecords: that.updateRecordsList1,
                  },
                  purpculresult: {
                      insertRecords: this.insertRecordsList2,
                      removeRecords: this.removeRecordsList2,
                      // updateRecords: that.updateRecordsList2,
                  },
                  imdlpurpculresult:{
                      insertRecords:this.insertRecordsList3,
                      removeRecords:this.removeRecordsList3,
                  }
                  //purpinputmdlresult:this.$refs.imdlpurposeTable.getRecordset(),
              },
          });
          return response;
      },
      mediumDetailTableInsert(type) {
          if (type == 1) {
              var newRow = {
                  // purposeno: this.addParam.purposeno,
                  // samplenorules: "D3"
                  ...this.addParam,
              };
              let row = this.$refs.xTable2.getCurrentRow();
              var alld = this.$refs.xTable2.getTableData().fullData;
              if (row && alld.length > 0) {
                  newRow.seq = (row.seq / 10 - 1) * 10;
                  this.$refs.xTable2.insertAt(newRow, row).then(({ row }) => {
                      this.$nextTick(() => {
                          this.$refs.xTable2.setCurrentRow(row);
                      });
                  });
              } else {
                  this.$refs.xTable2.insert(newRow).then(({ row }) => {
                      this.$nextTick(() => {
                          this.$refs.xTable2.setCurrentRow(row);
                      });
                  });
              }
          }
          if (type == 2) {
              if (!this.specbactRow.specimencode) {
                  this.$message.error("请先选择对应标本种类！");
                  return false;
              }
              var newRow = {
                  purposeno: this.addParam.purposeno,
                  // seq: this.$refs.bactTable.tableFullData.length > 0 ? (Math.floor(this.$refs.bactTable.tableFullData[this.$refs.bactTable.tableFullData.length - 1].seq / 10) + 1) * 10 : 10,
                  specimencode: this.specbactRow.specimencode,
              };
              let row = this.$refs.bactTable.getCurrentRow();
              var alld = this.$refs.bactTable.getTableData().fullData;
              if (row && alld.length > 0) {
                  newRow.seq = (row.seq / 10 - 1) * 10;
                  this.$refs.bactTable.insertAt(newRow, row).then(({ row }) => {
                      this.$nextTick(() => {
                          this.$refs.bactTable.setCurrentRow(row);
                      });
                  });
              } else {
                  this.$refs.bactTable.insert(newRow).then(({ row }) => {
                      this.$nextTick(() => {
                          this.$refs.bactTable.setCurrentRow(row);
                      });
                  });
              }
          }
          if (type == 3) {
              var newRow = {
                  purposeno: this.addParam.purposeno,
                  // seq: this.$refs.purpculresultTable.tableFullData.length > 0 ? (Math.floor(this.$refs.purpculresultTable.tableFullData[this.$refs.purpculresultTable.tableFullData.length - 1].seq / 10) + 1) * 10 : 10,
                  specimencode: this.specpurposeRow.specimencode,
              };
              let row = this.$refs.purpculresultTable.getCurrentRow();
              var alld = this.$refs.purpculresultTable.getTableData().fullData;
              if (row && alld.length > 0) {
                  newRow.seq = (row.seq / 10 - 1) * 10;
                  this.$refs.purpculresultTable.insertAt(newRow, row).then(({ row }) => {
                      this.$nextTick(() => {
                          this.$refs.purpculresultTable.setCurrentRow(row);
                      });
                  });
              } else {
                  this.$refs.purpculresultTable.insert(newRow).then(({ row }) => {
                      this.$nextTick(() => {
                          this.$refs.purpculresultTable.setCurrentRow(row);
                      });
                  });
              }
          }
          if(type==4){
              var newRow={
                  purposeno: this.addParam.purposeno,
                  specimencode: this.imdlspecpurposeRow.specimencode,
              }
              let row = this.$refs.imdlpurposeTable.getCurrentRow();
              var alld = this.$refs.imdlpurposeTable.getTableData().fullData;
              if(row && alld.length>0){
                  newRow.seq = (row.seq / 10 - 1) * 10;
                  this.$refs.imdlpurposeTable.insertAt(newRow, row).then(({ row }) => {
                      this.$nextTick(() => {
                          this.$refs.imdlpurposeTable.setCurrentRow(row);
                      });
                  });
              }else{
                  this.$refs.imdlpurposeTable.insert(newRow).then(({ row }) => {
                      this.$nextTick(() => {
                          this.$refs.imdlpurposeTable.setCurrentRow(row);
                      });
                  });
              }
          }
          this.hasChange();
      },
      mediumDetailTableDelete(tableName) {
          var delrow = this.$refs[tableName].getCurrentRow();
          var havedata = this.$refs[tableName].getTableData().fullData;
          if (delrow && havedata.length > 0) {
              var rowindex = havedata.indexOf(delrow);
              if (havedata.length > 0) {
                  this.$refs[tableName].remove(delrow);
                  if (rowindex == havedata.length - 1) rowindex--;
                  let selectrow = this.$refs[tableName].getTableData().fullData[rowindex];
                  this.$refs[tableName].setCurrentRow(selectrow);
              }
              this.hasChange();
          } else {
              this.$message({
                  message: "请先选中要删除的明细！",
                  type: "warning",
              });
          }
      },
      // 回车切换输入框
      nextFocus(id, index) {
          if (index <= 15) {
              var that = this;
              var focusIndex = index + 1;
              setTimeout(function () {
                  let lref = "input" + id;
                  if (index == 2) {
                      that.$refs[lref + focusIndex].$refs.ddlmainSelect.focus();
                      return false;
                  } else if (index == 3) {
                      that.$refs[lref + index].$refs.ddlmainSelect.blur();
                      //     focusIndex = index + 2;
                      //     that.$refs["input" + id + focusIndex].focus();
                  }
                  that.$refs[lref + focusIndex].focus();
              }, 1);
          }
      },
      chooseChargeRule(chargeid, detail) {
          // console.log(chargeid)
          var purposeno = "";
          var purposename = "";
          if (detail) {
              this.detailtype = 1;
              purposeno = this.detailrow.purposeno;
              purposename = this.detailrow.purposename;
          } else {
              this.detailtype = 0;
              purposeno = this.addParam.purposeno;
              purposename = this.addParam.purposename;
          }
          if (purposeno) {
              if (detail != 1 && !purposename) {
                  this.$message({
                      message: "请先输入检验目的代码和名称！",
                      type: "warning",
                  });
                  return false;
              }
              // this.$refs.xTable3.loadData([]);
              this.curCreateStep = chargeid;
              if (chargeid == 0) {
                  this.chargeType = 1;
                  this.chargeruleTitle = "申请科室对应输入模板";
                  this.querypopdetail(this.chargeType, "");
              } else {
                  this.chargeType = 2;
                  this.chargeruleTitle = "自动计价特殊规则";
                  this.querypopdetail(this.chargeType, chargeid);
              }
              if (chargeid != 0) {
                  this.chargeruleVisible2 = true;
              } else {
                  this.chargeruleVisible = true;
              }
          } else {
              this.$message({
                  message: "请先输入检验目的代码和名称！",
                  type: "warning",
              });
          }
      },
      querypopdetail(datatype, create_step) {
          console.log(this.detailrow);
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS835",
                  method: "post",
                  data: {
                      action: "querypopdetail",
                      datatype: datatype,
                      purposeno: this.addParam.purposeno,
                      specimen_code: this.detailtype == 1 ? this.detailrow.specimencode : "ALL",
                      create_step: create_step,
                  },
              })
              .then((response) => {
                  this.chargeRuleList = response.data;
              })
              .catch((e) => {});
      },
      chargeRuleDeal(type) {
          console.log(type, this.curCreateStep);
          if (type == 1) {
              console.log(this.detailtype == 1 ? this.detailrow.specimencode : "ALL");
              var insertParam = {
                  purposeno: this.addParam.purposeno,
                  purposename: this.addParam.purposename,
                  specimen_code: this.detailtype == 1 ? this.detailrow.specimencode : "ALL",
                  specimen_name: this.detailtype == 1 ? this.detailrow.specimen_name : "ALL",
                  create_step: this.curCreateStep,
              };
              if (this.curCreateStep != 0) {
                  // 计费节点
                  var create_stepname = this.curCreateStepList.find((item) => item.value == this.curCreateStep);
                  if (create_stepname) {
                      insertParam.create_step1 = create_stepname.name;
                      // console.log(create_stepname.name);
                  }
                  this.$refs.xTable4.insert(insertParam).then(({ row }) => {
                      this.$nextTick(() => {
                          this.$refs.xTable4.setCurrentRow(row);
                      });
                  });
              } else {
                  this.$refs.xTable3.insert(insertParam).then(({ row }) => {
                      this.$nextTick(() => {
                          this.$refs.xTable3.setCurrentRow(row);
                      });
                  });
              }
              // console.log(insertParam);
          }
          if (type == 2) {
              var table = "xTable3";
              if (this.chargeType == 2) {
                  table = "xTable4";
              }
              var delrow = this.$refs[table].getCurrentRow();
              var havedata = this.$refs[table].getTableData().fullData;
              console.log(delrow);
              console.log(havedata.length);
              if (delrow && havedata.length > 0) {
                  var rowindex = havedata.indexOf(delrow);
                  this.$refs[table].remove(delrow);
                  if (havedata.length > 0) {
                      if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                      let selectrow = havedata[rowindex];
                      console.log(selectrow);
                      this.$refs[table].setCurrentRow(selectrow);
                  }
                  this.hasChange();
              } else {
                  this.$message({
                      message: "请先选中要删除的明细！",
                      type: "warning",
                  });
              }
          }
          if (type == 3) {
              var table = "xTable3";
              if (this.chargeType == 2) {
                  table = "xTable4";
              }
              var param = {
                  datatype: this.chargeType,
                  purposeno: this.addParam.purposeno,
                  specimen_code: this.detailtype == 1 ? this.detailrow.specimencode : "ALL",
                  datastr: this.$refs[table].getTableData().fullData,
              };
              if (this.chargeType != 1) {
                  param.create_step = this.curCreateStep;
              }
              console.log(param);
              this.$tool
                  .request({
                      url: "LIS/LIS8/LIS835",
                      method: "post",
                      data: {
                          action: "savepopdata",
                          ...param,
                      },
                  })
                  .then((response) => {
                      if (response.errcode == 1) {
                          this.chargeruleVisible = false;
                          this.chargeruleVisible2 = false;
                          this.$message({
                              message: "保存成功！",
                              type: "success",
                          });
                      } else {
                          this.$message({
                              message: "保存成功，" + response.errmsg,
                              type: "warning",
                          });
                      }
                  })
                  .catch((e) => {});
          }
          if (type == 4) {
              this.chargeruleVisible = false;
              this.chargeruleVisible2 = false;
              // this.$refs.xTable3.getTableData().fullData = [];
              // this.chargeRuleList = [];
          }
      },
      mediumnoRule() {
          this.dialogTableVisible = true;
          this.mediumnoParam.no8 = this.addParam.samplenorules;
          this.dealMediumno(this.addParam.samplenorules);
          this.changetype = 0;
      },
      CellDblclick({ row, column }) {
          this.detailrow = row;
          // 明细表编号规则弹窗
          if (column.property == "samplenorules") {
              this.dialogTableVisible = true;
              // this.detailrow = row;
              this.mediumnoParam.no8 = row.samplenorules;
              this.dealMediumno(row.samplenorules);
              this.changetype = 1;
          }
          if (column.property == "definputmdl") {
              this.chooseChargeRule(0, 1);
          }
          if (column.property == "input_chargeid") {
              this.chooseChargeRule(1, 1);
          }
          if (column.property == "pos_chargeid") {
              this.chooseChargeRule(2, 1);
          }
          if (column.property == "pospercul_chargeid") {
              this.chooseChargeRule(3, 1);
          }
          if (column.property == "preeval_chargeid") {
              this.chooseChargeRule(4, 1);
          }
      },
      sureRule() {
          this.dialogTableVisible = false;
          if (this.changetype == 0) {
              this.addParam.samplenoSample = this.mediumnoParam.no7;
              this.addParam.samplenorules = this.mediumnoParam.no8;
          } else if (this.changetype == 1) {
              this.detailrow.samplenoSample = this.mediumnoParam.no7;
              this.detailrow.samplenorules = this.mediumnoParam.no8;
          }
          this.hasChange();
      },
      closeDialog() {
          this.dialogTableVisible = false;
      },
      dealMediumno(mediumnorule) {
          console.log(mediumnorule);
          var splitStr = mediumnorule.split(";");
          var endstr=splitStr[splitStr.length-1];
          if(endstr=="Y" || endstr=="M" || endstr=="W" || endstr=="D"){
              this.mediumnoParam.no9=endstr;
              mediumnorule=mediumnorule.replace(";"+endstr,"");
          }else{
              this.mediumnoParam.no9="";
          }
          console.log(mediumnorule);
          splitStr = mediumnorule.split(";");
          console.log(splitStr);
          var str = splitStr[0].split("");
          var noListValue = ["D", "#", "$", "Y", ""];
          if (splitStr.length > 1) {
              if (splitStr[1]) {
                  this.mediumnoParam.no4 = splitStr[1];
              }
              if (splitStr[2]) {
                  this.mediumnoParam.no5 = splitStr[2];
              }
          } else {
              this.mediumnoParam.no4 = "";
              this.mediumnoParam.no5 = "";
          }
          if (str.length > 2) {
              this.mediumnoParam.no3 = str[2];
              if (noListValue.indexOf(str[0]) > -1) {
                  this.mediumnoParam.no1 = str[0];
                  this.mediumnoParam.no6 = false;
              }
              if (this.noList1.indexOf(str[0]) > -1) {
                  this.mediumnoParam.no2 = str[0];
                  this.mediumnoParam.no6 = true;
              }
              if (noListValue.indexOf(str[1]) > -1) {
                  this.mediumnoParam.no1 = str[1];
                  this.mediumnoParam.no6 = true;
              }
              if (this.noList1.indexOf(str[1]) > -1) {
                  this.mediumnoParam.no2 = str[1];
                  this.mediumnoParam.no6 = false;
              }
          } else {
              this.mediumnoParam.no3 = str[1];
              if (noListValue.indexOf(str[0]) > -1) {
                  this.mediumnoParam.no1 = str[0];
                  this.mediumnoParam.no2 = "空";
              }
              if (this.noList1.indexOf(str[0]) > -1) {
                  this.mediumnoParam.no2 = str[0];
                  this.mediumnoParam.no1 = "";
              }
          }
          this.mediumnoArea();
      },
      mediumnoArea(no) {
          var ruleStr = [];
          var area = [];
          var str = "";
          var str1 = "";
          var str2 = "";
          var str3 = "";
          if(no){
              if((no-0)==1){
                  this.mediumnoParam.no9="";
              }
          }
          if(this.mediumnoParam.no1 == "#"){
              this.mediumnoParam.no9="";
              this.typedisable=true;
          }else{
              this.typedisable=false;
          }
          this.noList3=XEUtils.clone(this.noList3_D,true);
          if (this.mediumnoParam.no1 == "D" || this.mediumnoParam.no1 == "#") {
              str = XEUtils.toDateString(new Date(), "yyMMdd");
          }
          if (this.mediumnoParam.no1 == "$") {
              str = XEUtils.toDateString(new Date(), "yyMM");
              this.noList3=XEUtils.clone(this.noList3_M,true);
          }
          if (this.mediumnoParam.no1 == "Y") {
              str = XEUtils.toDateString(new Date(), "yy");
              this.noList3=XEUtils.clone(this.noList3_Y,true);
          }
          if (this.mediumnoParam.no2 != null && this.mediumnoParam.no2 != "") {
              str1 = this.mediumnoParam.no2;
          }
          if (this.mediumnoParam.no3) {
              if (this.mediumnoParam.no4 == undefined || this.mediumnoParam.no4 == "") {
                  str2 = this.preZeroFill("0", Number(this.mediumnoParam.no3));
              } else if (this.mediumnoParam.no4.toString().length > Number(this.mediumnoParam.no3)) {
                  this.mediumnoParam.no4 = this.mediumnoParam.no4.substr(0, Number(this.mediumnoParam.no3));
              } else {
                  str2 = this.preZeroFill(this.mediumnoParam.no4, Number(this.mediumnoParam.no3));
              }
              if (this.mediumnoParam.no5 == undefined || this.mediumnoParam.no5 == "") {
                  str3 = Math.pow(10, this.mediumnoParam.no3) - 1;
              } else if (this.mediumnoParam.no5.toString().length > Number(this.mediumnoParam.no3)) {
                  this.mediumnoParam.no5 = this.mediumnoParam.no5.substr(0, Number(this.mediumnoParam.no3));
              } else {
                  str3 = this.preZeroFill(this.mediumnoParam.no5, Number(this.mediumnoParam.no3));
              }
          }
          ruleStr[0] = this.mediumnoParam.no1 ? this.mediumnoParam.no1 : "";
          ruleStr[1] = (this.mediumnoParam.no2 ? this.mediumnoParam.no2 : "").replace(/空/, "");
          ruleStr[2] = this.mediumnoParam.no3 ? this.mediumnoParam.no3 : "";
          if (this.mediumnoParam.no6) {
              area[0] = (str1 + str + str2).replace(/空/, "");
              area[1] = (str1 + str + str3).replace(/空/, "");
              this.mediumnoParam.no7 = area[0] + "-" + area[1];
              // console.log(ruleStr[0] + ruleStr[1] + ruleStr[2])
              ruleStr[3] = this.mediumnoParam.no4 ? ";" + this.mediumnoParam.no4 : "";
              ruleStr[4] = this.mediumnoParam.no5 ? ";" + this.mediumnoParam.no5 : "";
              var part = ruleStr[1] + ruleStr[0] + ruleStr[2] + ruleStr[3];
              if (this.mediumnoParam.no5 && part.indexOf(";") < 0) {
                  this.mediumnoParam.no8 = ruleStr[1] + ruleStr[0] + ruleStr[2] + ruleStr[3] + ";" + ruleStr[4];
              } else {
                  this.mediumnoParam.no8 = ruleStr[1] + ruleStr[0] + ruleStr[2] + ruleStr[3] + ruleStr[4];
              }
          } else {
              area[0] = (str + str1 + str2).replace(/空/, "");
              area[1] = (str + str1 + str3).replace(/空/, "");
              this.mediumnoParam.no7 = area[0] + "-" + area[1];
              ruleStr[3] = this.mediumnoParam.no4 ? ";" + this.mediumnoParam.no4 : "";
              ruleStr[4] = this.mediumnoParam.no5 ? ";" + this.mediumnoParam.no5 : "";
              var part = ruleStr[1] + ruleStr[0] + ruleStr[2] + ruleStr[3];
              if (this.mediumnoParam.no5 && part.indexOf(";") < 0) {
                  this.mediumnoParam.no8 = ruleStr[0] + ruleStr[1] + ruleStr[2] + ruleStr[3] + ";" + ruleStr[4];
              } else {
                  this.mediumnoParam.no8 = ruleStr[0] + ruleStr[1] + ruleStr[2] + ruleStr[3] + ruleStr[4];
              }
          }
          if(this.mediumnoParam.no9){
              this.mediumnoParam.no8=this.mediumnoParam.no8+";"+this.mediumnoParam.no9;
          }
          // this.addParam.samplenoSample = this.mediumnoParam.no7;
      },
      preZeroFill(num, size) {
          console.log(num, size);
          if (num >= Math.pow(10, size)) {
              return num.toString();
          } else {
              var _str = Array(size + 1).join("0") + num;
              return _str.slice(_str.length - size);
          }
      },
      culresultDblEvent({ row, rowIndex, $rowIndex, column }) {
          switch (column.property) {
              case "rpt_itemname":
                  this.dialogRptVisible = true;
                  this.$nextTick(() => {
                      this.$refs.rptdialog.$refs.qcodeinput.focus();
                  });
                  this.selrow = row;
                  break;
              case "defaultresult_str":
                  this.QueryResultAll(row.rpt_itemcode,0);
                  break;
          }
      },
      //双击弹窗添加项目
      addrptitem(c, n, row) {
          var currentrow = this.$refs.purpculresultTable.getCurrentRow();
          // console.log(this.$refs.purpculresultTable.tableFullData);
          if (this.$refs.purpculresultTable.tableFullData.length > 1) {
              var hasrow = this.$refs.purpculresultTable.tableFullData.find((item) => item.rpt_itemcode == c);
              if (hasrow) {
                  this.$confirm("不能选择重复的项目", "提示", {
                      confirmButtonText: "确定",
                      cancelButtonText: "取消",
                      focusCancelButton: false,
                      type: "warning",
                  });
                  currentrow.rpt_itemname = "";
                  this.$refs.purpculresultTable.setActiveCell(currentrow, "rpt_itemname").then(() => {
                      if (this.$refs.rptitemname) {
                          this.$refs.rptitemname.focus();
                      }
                  });
              } else {
                  currentrow.rpt_itemcode = c;
                  currentrow.rpt_itemname = n;
                  currentrow.germflag = row.germflag;
                  this.hasChange();
              }
          } else {
              currentrow.rpt_itemcode = c;
              currentrow.rpt_itemname = n;
              currentrow.germflag = row.germflag;
              this.hasChange();
          }
          this.dialogRptVisible = false;
      },
      async rptitemInput(row) {
          if (!this.ddlData.length) {
              this.ddlData = await this.$ddldata.getallrptitem();
              this.ddlData = this.ddlData.filter((item) => item.germflagid != "0");
          }
          var select = this.ddlData.find((item) => item.rpt_itemcode.toUpperCase() == row.rpt_itemname.toUpperCase() || item.itemcode_en.toUpperCase() == row.rpt_itemname.toUpperCase() || item.rpt_itemname.toUpperCase() == row.rpt_itemname.toUpperCase() || item.inputcode.toUpperCase() == row.rpt_itemname.toUpperCase());
          if (select) {
              this.tempRptItem = row;
              this.addrptitem(select.rpt_itemcode, select.rpt_itemname, select);
              this.hasChange();
          } else {
              row.rpt_itemname = "";
          }
      },
      getAllList(type) {
          if (type == 1) {
              if (this.$refs.bactTable.getRecordset().insertRecords.length > 0) this.insertRecordsList1 = this.insertRecordsList1.concat(this.$refs.bactTable.getRecordset().insertRecords);
              if (this.$refs.bactTable.getRecordset().removeRecords.length > 0) {
                  this.$refs.bactTable.getRecordset().removeRecords.forEach((item) => {
                      this.isAreaIs(type, item);
                  });
              }
              var updateList = this.$refs.bactTable.getRecordset().updateRecords;
              if (updateList.length > 0) {
                  updateList.forEach((element) => {
                      this.insertRecordsList1.push(element.cdata);
                      this.isAreaIs(type, element.odata);
                  });
              }
          }
          if (type == 2) {
              if (this.$refs.purpculresultTable.getRecordset().insertRecords.length > 0) this.insertRecordsList2 = this.insertRecordsList2.concat(this.$refs.purpculresultTable.getRecordset().insertRecords);
              if (this.$refs.purpculresultTable.getRecordset().removeRecords.length > 0) {
                  this.$refs.purpculresultTable.getRecordset().removeRecords.forEach((item) => {
                      this.isAreaIs(type, item);
                  });
              }
              // this.removeRecordsList2 = this.removeRecordsList2.concat(this.$refs.purpculresultTable.getRecordset().removeRecords);
              // this.updateRecordsList2 = this.updateRecordsList2.concat(this.$refs.purpculresultTable.getRecordset().updateRecords);
              var updateList = this.$refs.purpculresultTable.getRecordset().updateRecords;
              if (updateList.length > 0) {
                  updateList.forEach((element) => {
                      this.insertRecordsList2.push(element.cdata);
                      // this.removeRecordsList2.push(element.odata);
                      this.isAreaIs(type, element.odata);
                  });
              }
          }
          if(type==3){
              if (this.$refs.imdlpurposeTable.getRecordset().insertRecords.length > 0) this.insertRecordsList3 = this.insertRecordsList3.concat(this.$refs.imdlpurposeTable.getRecordset().insertRecords);
              if (this.$refs.imdlpurposeTable.getRecordset().removeRecords.length > 0) {
                  this.$refs.imdlpurposeTable.getRecordset().removeRecords.forEach((item) => {
                      this.isAreaIs(type, item);
                  });
              }
              var updateList = this.$refs.imdlpurposeTable.getRecordset().updateRecords;
              if (updateList.length > 0) {
                  updateList.forEach((element) => {
                      this.insertRecordsList3.push(element.cdata);
                      // this.removeRecordsList2.push(element.odata);
                      this.isAreaIs(type, element.odata);
                  });
              }
          }
      },
      isAreaIs(type, item) {
          if (type == 1) {
              let index = this.insertRecordsList1.findIndex((t) => t.purposeno == item.purposeno && t.specimencode == item.specimencode && t.mediumgroupno == item.mediumgroupno && t.seq == item.seq);
              if (index > -1) {
                  this.insertRecordsList1.splice(index, 1);
              } else {
                  // this.removeRecords = this.removeRecordsList1.concat(this.$refs.bactTable.getRecordset().removeRecords);
                  this.removeRecordsList1.push(item);
              }
          }
          if (type == 2) {
              let index = this.insertRecordsList2.findIndex((t) => t.purposeno == item.purposeno && t.specimencode == item.specimencode && t.rpt_itemcode == item.rpt_itemcode && t.defaultneg == item.defaultneg && t.seq == item.seq && t.defaultresult_str == item.defaultresult_str && t.bloodculture == item.bloodculture) ;
              if (index > -1) {
                  this.insertRecordsList2.splice(index, 1);
              } else {
                  // this.removeRecords = this.removeRecordsList1.concat(this.$refs.bactTable.getRecordset().removeRecords);
                  this.removeRecordsList2.push(item);
              }
          }
          if(type ==3 ){
               let index = this.insertRecordsList3.findIndex((t) => t.purposeno == item.purposeno && t.specimencode == item.specimencode && t.inputmdlid == item.inputmdlid && t.seq == item.seq);
               if(index>-1){
                  this.insertRecordsList3.splice(index, 1);
               }else{
                  this.removeRecordsList3.push(item);
               }
          }
      },
      ExportCsv() {
          let p = { prgno: "LIS835" }
          this.$pub.commexport(this, p, `微生物检验目的.dat`)
      },
      ImportCsv() {
          this.$refs["upload"].$refs["upload-inner"].handleClick();
      },
      // 上传文件之前的钩子, 参数为上传的文件,若返回 false 或者返回 Promise 且被 reject，则停止上传
      beforeUploadFile(file) {
          let extension = file.name.substring(file.name.lastIndexOf(".") + 1);
          let size = file.size / 1024 / 1024;
          if (extension !== "dat") {
              this.$notify.warning({
                  title: "警告",
                  message: `只能上传DAT(*dat)文件，且不超过10M`,
              });
          }
          if (size > 10) {
              this.$notify.warning({
                  title: "警告",
                  message: `文件大小不得超过10M`,
              });
          }
      },
      uploadOpt(content) {
          let formData = new FormData();
          formData.append("action", "BACCOMMOMUPLOAD");
          formData.append("file", content.file);
          this.$pub.uploadFileOpt(this, formData, "queryBactPurpose");
      },
      // 文件状态改变时的钩子
      fileChange(file, fileList) {
          this.form.file = file.raw;
      },
      QueryResultAll(rptitemcode, rekind) {
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS310",
                  method: "post",
                  data: {
                      action: "getrptitemval",
                      rpt_itemcode: rptitemcode,
                      resultkind: rekind,
                      rptunitid: this.rptunitid,
                  },
              })
              .then((res) => {
                  //console.log(res);
                  this.tableColumnResultAll = res.Cols;
                  this.tableDataResultAll = res.Data;
                  this.tableDataResultS = res.Data;
                  this.dialogResultVisible = true;
              });
      },
      //Result弹出框的各项方法
      ResultSearchkeydown() {
          if (this.tableDataResultAll && this.tableDataResultAll.length > 0) {
              this.tableDataResultS = this.tableDataResultAll.filter((item) => item.textvalue.toUpperCase().indexOf(this.Resultqcode.toUpperCase()) > -1 || item.inputcode.toUpperCase().indexOf(this.Resultqcode.toUpperCase()) > -1 || (item.seq + "").indexOf(this.Resultqcode.toUpperCase()) > -1);
          } else {
              this.tableDataResultS = [];
          }
      },
      Resultok() {
          var row = this.$refs.xTableResultAll.getCurrentRow();
          if (row) {
              var uprow = this.$refs.purpculresultTable.tableFullData.filter((item) => item.rpt_itemcode == row.rpt_itemcode)[0];
              // uprow.result_flag = row.result_flag;
              // uprow.redoflag = row.redoflag;
              // uprow.limitflag = row.limitflag;
              uprow.defaultresult_str = row.textvalue;
              this.dialogResultVisible = false;
              this.hasChange();
          } else {
              this.$message({
                  showClose: true,
                  message: "未选中报告结果!",
                  type: 'warning'
              });
          }
      },
      Resultcancel() {
          this.dialogResultVisible = false;
      },
      ResultSelect({ row }) {
          var uprow = this.$refs.purpculresultTable.tableFullData.filter((item) => item.rpt_itemcode == row.rpt_itemcode)[0];
          // uprow.result_flag = row.result_flag;
          // uprow.redoflag = row.redoflag;
          // uprow.limitflag = row.limitflag;
          uprow.defaultresult_str = row.textvalue;
          this.dialogResultVisible = false;
          this.hasChange();
      },
  },
};
</script>

<style scoped>
table {
  font-size: 12px;
  border-collapse: separate;
  border-spacing: 5px;
}
.page-container {
  position: absolute;
  top: 0px;
  width: 100%;
  left: 0;
  bottom: 0;
  padding: 0;
  display: flex;
}
.page-top {
  width: 100%;
  height: 38px;
  border: 1px solid #ccc;
  position: absolute;
  font-size: 12px;
  display: flex;
  padding: 5px 0;
  line-height: 24px;
}
.search-title {
  margin: 0 5px 0 20px;
}
.top-deal {
  right: 5px;
  position: absolute;
  height: 25px;
  display: flex;
  align-items: center;
}
.upload-button {
  height: 24px;
  margin: 0 10px;
  display: none;
}
.upload-button div {
  height: 24px;
}
.page-bottom {
  margin-top: 43px;
  position: absolute;
  font-size: 12px;
  width: 100%;
  height: calc(100% - 43px);
}
.detail-operation {
  display: flex;
  padding: 0px 2px 0px 5px;
  margin: 5px 0;
}
.mytable-style,
.bact-table {
  font-size: 12px;
}
.text-note {
  vertical-align: top;
}
.baseinfo {
  height: 100%;
  overflow-y: auto;
}
/deep/ .el-button.is-disabled {
  border: 0px;
  color: grey;
  background-color: #e6e6e6;
  font-weight: normal;
}
/deep/ .base-detail .el-form-item--small.el-form-item {
  margin-bottom: 0 !important;
}
.specimen-type {
  height: calc(100% - 30px) !important;
}
/deep/ .specimen-type .mytable-style {
  height: 100%;
}
/deep/ .specimen-type .vxe-table .vxe-table--body-wrapper {
  height: calc(100% - 30px);
}
/deep/ .mytable-style .vxe-header--row .vxe-header--column {
  line-height: 15px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
/deep/ .mytable-style .vxe-body--column {
  padding: 0 !important;
}
/deep/ .mytable-style .vxe-table .vxe-cell {
  padding-top: 0 !important;
}
/deep/ .bact-table .vxe-body--column {
  padding: 0 !important;
  height: 26px !important;
}
/deep/ .page-top .el-button--small {
  height: 24px !important;
}
/deep/ .mytable-style tr.vxe-body--row.row-new {
  color: #cc6600;
}
/deep/ .row-modify {
  color: blue;
}
/deep/ .search-textarea .el-textarea__inner {
  padding: 5px !important;
}
/deep/ .text-pane .vxe-cell {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
/deep/ .upload-button .el-upload--text {
  border: 0 !important;
  border-radius: 3px !important;
}
/deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
  border-color: #000000;
}
/deep/ .bact-table .vxe-header--row .vxe-header--column {
  line-height: 25px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
.bact {
  height: 300px;
  padding-bottom: 5px;
}
.bact-table {
  height: 100%;
}
.purpculresult {
  height: calc(100% - 300px);
}
/deep/ .mytable-style .vxe-table.size--mini .vxe-default-select {
  height: 26px !important;
}
/deep/ .bact-table .vxe-table.size--mini .vxe-default-select {
  height: 26px !important;
}
/deep/ .bact-table .vxe-table.vxe-editable .vxe-body--column {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
/deep/.specimen-type .el-input--small .el-input__inner {
  height: 26px !important;
  line-height: 26px !important;
}
</style>